fix: 코드 점검 — 시간대·외부 API·XSS·서버 블로킹 수정

- 네이버/카페24/발주 파일명/반품 입고일을 KST로 고정 (컨테이너 UTC 대응)
- 네이버 API timeout 추가, last-changed-statuses 'more' 페이지 이어서 조회, 주문번호 중복 제거
- 스마트스토어 발주확인을 엑셀 생성 이후로 이동
- 반품 신청/입고 목록 innerHTML 이스케이프 (XSS)
- 카페24 OAuth 콜백: 반사형 XSS 차단, /corm 경로로 복귀
- 블로킹 async 엔드포인트를 sync로 전환 (코드표·반품·송장 업로드·자사몰 행사·밀크런·CS 가져오기)
- DB 연결 closing 처리, 세트 목록 N+1 쿼리 제거
- 반품 일괄 입고 중복 송장 건너뛰기 및 안내
- 작업 결과 메모리 1시간 TTL, 401 로그인 next 경로 중복 수정
- 송장 '.0' 처리 수정 및 네이버/카페24 송장 파싱 공용화
- SortableJS 1.15.6 고정, 중복 코드·미사용 import 정리

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-22 20:30:26 +09:00
parent ae50500655
commit 7046a504a1
9 changed files with 561 additions and 667 deletions
+29 -24
View File
@@ -12,7 +12,8 @@
const response = await origFetch(input, init);
if (response.status === 401) {
// 세션 만료 — dbx-main 로그인으로 위임 (next 로 현재 위치 보존)
const next = encodeURIComponent((APP_BASE_PATH || '') + window.location.pathname + window.location.search);
// pathname 에 이미 /corm 이 들어 있으므로 APP_BASE_PATH 를 다시 붙이지 않는다.
const next = encodeURIComponent(window.location.pathname + window.location.search);
window.location.href = (APP_BASE_PATH || '') + '/login?next=' + next;
}
return response;
@@ -98,6 +99,16 @@ function formatShortDate(dateStr) {
return `${m}월 ${day}일(${dow})`;
}
// 서버·쇼핑몰에서 온 값(고객명, 주소, 비고 등)을 innerHTML에 넣기 전에 반드시 거친다.
function escapeHtml(str) {
return String(str == null ? '' : str)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;');
}
document.addEventListener('DOMContentLoaded', () => {
const ORDER_TYPE_LABELS = { noolak: '누락', pason: '파손', bullyang: '불량', misdelivery: '오배송', normal: '수동발주', ellen: '엘렌' };
const SPECIAL_ORDER_TYPES = new Set(['noolak', 'pason', 'bullyang', 'misdelivery']);
@@ -422,15 +433,6 @@ document.addEventListener('DOMContentLoaded', () => {
}
}
function escapeHtml(str) {
return String(str == null ? '' : str)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;');
}
function resetMilkrunResult() {
if (linesTbody) linesTbody.innerHTML = '';
if (linesInfo) linesInfo.textContent = '';
@@ -2843,6 +2845,9 @@ document.addEventListener('DOMContentLoaded', () => {
if (res.ok) {
const data = await res.json();
if (data.duplicates && data.duplicates.length) {
alert(`${data.count}건 등록했습니다.\n이미 입고된 송장 ${data.duplicates.length}건은 건너뛰었습니다:\n${data.duplicates.join('\n')}`);
}
bulkReceiveModal.style.display = 'none';
bulkTrackingNumbers.value = '';
updateBulkTrackingLineNumbers();
@@ -2906,7 +2911,7 @@ document.addEventListener('DOMContentLoaded', () => {
const isReceived = item.is_received;
const tr = document.createElement('tr');
tr.style.cursor = 'pointer';
let displayRemarks = item.remarks || '';
let displayRemarks = escapeHtml(item.remarks || '');
if (isReceived) {
tr.style.textDecoration = 'line-through';
tr.style.color = '#a0aec0';
@@ -2928,16 +2933,16 @@ document.addEventListener('DOMContentLoaded', () => {
if (item.request_date && !item.request_date.startsWith(todayStr)) {
tr.style.backgroundColor = '#cbd5e0';
}
const rowDataJson = JSON.stringify(item).replace(/'/g, "&apos;").replace(/"/g, "&quot;");
const rowDataJson = escapeHtml(JSON.stringify(item));
tr.innerHTML = `
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: center; width: 30px;" onclick="event.stopPropagation();">
<input type="checkbox" class="chk-req-row" data-item="${rowDataJson}" ${isReceived ? 'disabled' : ''}>
</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: center; white-space: nowrap; width: 100px;">${formatShortDate(item.request_date)}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: center; cursor: pointer; white-space: nowrap; width: 90px;" onclick="navigator.clipboard.writeText(this.innerText); showToast('이름이 복사되었습니다.');" title="클릭하여 복사">${item.receiver_name}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: left; cursor: pointer; white-space: nowrap; width: 130px;" onclick="navigator.clipboard.writeText(this.innerText); showToast('연락처가 복사되었습니다.');" title="클릭하여 복사">${item.phone}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: left; cursor: pointer; white-space: nowrap; width: 110px;" onclick="navigator.clipboard.writeText(this.innerText); showToast('송장번호가 복사되었습니다.');" title="클릭하여 복사">${item.tracking_no}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: center; white-space: nowrap; width: 65px;">${item.request_type}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: center; white-space: nowrap; width: 100px;">${escapeHtml(formatShortDate(item.request_date))}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: center; cursor: pointer; white-space: nowrap; width: 90px;" onclick="navigator.clipboard.writeText(this.innerText); showToast('이름이 복사되었습니다.');" title="클릭하여 복사">${escapeHtml(item.receiver_name)}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: left; cursor: pointer; white-space: nowrap; width: 130px;" onclick="navigator.clipboard.writeText(this.innerText); showToast('연락처가 복사되었습니다.');" title="클릭하여 복사">${escapeHtml(item.phone)}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: left; cursor: pointer; white-space: nowrap; width: 110px;" onclick="navigator.clipboard.writeText(this.innerText); showToast('송장번호가 복사되었습니다.');" title="클릭하여 복사">${escapeHtml(item.tracking_no)}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: center; white-space: nowrap; width: 65px;">${escapeHtml(item.request_type)}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: left; width: 215px;">${displayRemarks}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: center; width: 40px;" onclick="event.stopPropagation();">
<button class="btn-delete-req" data-id="${item.id}" style="background:none; border:none; color:red; cursor:pointer;">✕</button>
@@ -3023,13 +3028,13 @@ document.addEventListener('DOMContentLoaded', () => {
const isCompleted = (item.receive_status === '환불완료' || item.receive_status === '교환완료');
const statusStyle = isCompleted ? 'color: #e53e3e; font-weight: bold;' : '';
tr.innerHTML = `
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: center; white-space: nowrap; width: 100px;">${formatShortDate(item.receive_date)}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: center; cursor: pointer; white-space: nowrap; width: 90px;" onclick="navigator.clipboard.writeText(this.innerText); showToast('이름이 복사되었습니다.');" title="클릭하여 복사">${item.receiver_name}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: left; cursor: pointer; white-space: nowrap; width: 130px;" onclick="navigator.clipboard.writeText(this.innerText); showToast('연락처가 복사되었습니다.');" title="클릭하여 복사">${item.phone}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: left; cursor: pointer; white-space: nowrap; width: 110px;" onclick="navigator.clipboard.writeText(this.innerText); showToast('송장번호가 복사되었습니다.');" title="클릭하여 복사">${item.tracking_no}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: center; white-space: nowrap; width: 85px;">${item.mall || ''}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: center; white-space: nowrap; width: 65px; ${statusStyle}">${item.receive_status}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: left; width: 160px;">${(item.remarks || '').replace(/맞교환/g, `<span style=\"color: red;\">맞교환</span>`)}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: center; white-space: nowrap; width: 100px;">${escapeHtml(formatShortDate(item.receive_date))}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: center; cursor: pointer; white-space: nowrap; width: 90px;" onclick="navigator.clipboard.writeText(this.innerText); showToast('이름이 복사되었습니다.');" title="클릭하여 복사">${escapeHtml(item.receiver_name)}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: left; cursor: pointer; white-space: nowrap; width: 130px;" onclick="navigator.clipboard.writeText(this.innerText); showToast('연락처가 복사되었습니다.');" title="클릭하여 복사">${escapeHtml(item.phone)}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: left; cursor: pointer; white-space: nowrap; width: 110px;" onclick="navigator.clipboard.writeText(this.innerText); showToast('송장번호가 복사되었습니다.');" title="클릭하여 복사">${escapeHtml(item.tracking_no)}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: center; white-space: nowrap; width: 85px;">${escapeHtml(item.mall)}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: center; white-space: nowrap; width: 65px; ${statusStyle}">${escapeHtml(item.receive_status)}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: left; width: 160px;">${escapeHtml(item.remarks).replace(/맞교환/g, `<span style=\"color: red;\">맞교환</span>`)}</td>
<td style="padding: 8px; border-bottom: 1px solid #e2e8f0; text-align: center; width: 40px;" onclick="event.stopPropagation();">
<button class="btn-delete-rec" data-id="${item.id}" style="background:none; border:none; color:red; cursor:pointer;">✕</button>
</td>