Merge: 7.0.7 병렬 검수 수정분 통합 — 구조분해·JSON-LD 중복 구현 단일화, 양측 고유 수정 보존

동일 결함 2건(표현식 배열 구조분해 회귀, JSON-LD 이스케이프)을 양 세션이 독립
구현해 충돌. 해소 기준:

- 평가기 구조분해: JS iterator 시맨틱 구현 채택(구 평가기 new Function 패리티가
 회귀 수정의 본래 의도). 관대(undefined) 바인딩 구현과 그 단언 1건은 폐기.
 단위 테스트는 양측 병합(구조분해 10케이스), E2E·시나리오 축은
 destructuring_param 단일 케이스로 통합. 무관 심볼의 @since 소급 변경은 원복.
- JSON-LD: JSON_HEX_TAG|JSON_HEX_AMP(상위집합) 채택, XSS 단위 테스트 중복 제거.
- 양측 고유 수정 각각 보존: composeTitleSuffix 접미사 조립(타 세션) /
 스케줄 확장 명령 웹 검증 폴백·SeoMetaResolverTest 설정 격리(본 세션).
- min.js 는 병합 소스로 core:build --production 재빌드.

검증: SafeExpressionEvaluator 120/120, SeoMetaResolverTest 68/68, 배포 번들
E2E 6/6. 실측 — 게시판 환경설정 권한 섹션 60컨트롤 렌더, 장바구니 담기 201,
봇 title 접미사 공백 복원·매달린 구분자 제거, 검색 XSS 봇/_escaped_fragment_
양 경로 이스케이프 확인.
This commit is contained in:
HeuJung committed 2026-08-18 10:16:50 +09:00
commit 4b986be0b2
10 files changed
+208 -92

No files matched your search

@@ -9,10 +9,11 @@
### Fixed
#### 화살표/함수 파라미터의 배열 구조 분해 지원 (`([key]) => …`)
#### 화살표/함수 파라미터 배열 구조분해 미지원 회귀 (장바구니/바로구매 불능·권한 computed 공백)
- SafeExpressionEvaluator 파서가 화살표·함수 파라미터를 평문 식별자만 허용해, 레이아웃 전반에서 실사용 중인 `Object.entries(...).filter(([key]) => …)` / `.map(([k, v]) => …)` / `([, v]) => …` 형태가 `Expected ")" but found "=>"` 로 평가 실패했다. 게시판 환경설정의 권한 기본값 computed 4종이 계산되지 않아 권한 섹션이 헤더만 남고 비었고, 플러그인 설정·이커머스 폼의 검증 오류 표시(`([field, messages]) => …`)도 발화 시점에 같은 실패에 걸리는 상태였다 (7.0.7 평가기 교체 회귀 — 배포 레이아웃 60여 파일 사용).
- 파라미터 목록 파서에 평탄한 배열 구조 분해 패턴(식별자 + 엘리전 홀)을 추가하고, 바인딩 시 홀은 건너뛰며 대상이 null/undefined 여도 예외 없이 undefined 를 바인딩한다. 중첩 패턴·rest·객체 구조 분해는 배포 레이아웃 사용이 0건이라 지원하지 않는다(형태가 어긋나면 종전과 같이 arrow 판정을 되돌린다).
- engine-v1.60.0 의 SafeExpressionEvaluator 교체가 구 평가기(`new Function`)가 허용하던 **화살표·함수 파라미터의 배열 구조분해**(`([k, v]) =>`, `([, vid]) =>`)를 수용하지 않아, 해당 문법을 쓰는 표현식이 전부 `Expected ")" but found "=>"` 로 파싱 실패했다. 액션 params 는 미평가 원문 문자열 그대로 서버에 전송되어 422 가 되고(스토어프론트 장바구니 담기·바로 구매가 전 상품에서 불능), 게시판 환경설정의 권한 기본값 computed 4종이 계산되지 않아 권한 섹션이 비었으며, 플러그인 설정·이커머스 폼의 검증 오류 표시(`([field, messages]) => …`)도 발화 시점에 같은 실패에 걸리는 상태였다. 저장소 레이아웃 54개 파일 104곳이 이 문법을 사용 중이었다.
- `tryParseParamList` 에 배열 패턴(식별자 + 홀/elision, 파라미터 기본값 조합 포함)을 추가하고 `bindParams` 가 JS iterator 시맨틱(비-iterable 은 TypeError)으로 분해 바인딩하도록 했다. 중첩 패턴·rest·객체 패턴은 배포 레이아웃 사용 0건이라 지원하지 않는다(발견 시 arrow 아님으로 안전 되돌림).
- 회귀 잠금: 사용 형태 전수(단일/쌍/홀/기본값/function 선언 파라미터/실전 `_purchase_card.json` 본문·게시판 권한 computed·검증 오류 표시) 단위 테스트 + 배포 번들 E2E(`destructuring_param`) 추가.
## [engine-v1.60.4] - 2026-08-14
@@ -248,10 +248,11 @@ type Node =
/**
* 함수/화살표 파라미터 (기본값 지원).
*
* 배열 구조 분해 패턴(`([key]) => …`, `([, v]) => …`)은 `name: null` +
* `elements` 로 표현한다. `elements` 의 `null` 항목은 엘리전 홀(`[, v]`)이다.
* 레이아웃 실사용 형태(`Object.entries(...).map(([k, v]) => …)`)가 이 문법에
* 의존하므로 평문 식별자와 동급으로 지원한다. (engine-v1.60.5)
* `name` 이 null 이면 배열 구조분해 패턴 — `elements` 가 요소 이름 목록이며
* null 요소는 홀(elision)이다 (`([, vid]) =>` → elements: [null, 'vid']).
* 구 평가기(new Function)가 허용하던 형태로, 레이아웃 전반에서 사용된다.
*
* @since engine-v1.60.5
*/
interface Param {
name: string | null;
@@ -766,8 +767,8 @@ class Parser {
}
/**
* 파라미터 목록을 파싱한다: `ident (= 기본값)?` 를 `,` 로 구분. 열림 `(` 는 호출부가
* 이미 소비한 상태이며, 닫힘 `)` 는 소비하지 않는다(호출부가 검사).
* 파라미터 목록을 파싱한다: `(ident | [배열패턴]) (= 기본값)?` 를 `,` 로 구분.
* 열림 `(` 는 호출부가 이미 소비한 상태이며, 닫힘 `)` 는 소비하지 않는다(호출부가 검사).
*
* @return 파싱된 파라미터 배열, 또는 파라미터 형태가 아니면 null(arrow 아님)
*/
@@ -779,16 +780,14 @@ class Parser {
let name: string | null = null;
let elements: (string | null)[] | undefined;
if (p && p.type === 'punct' && p.value === '[') {
// 배열 구조 분해 패턴: [a, b] / [, v] / [a,] — 평탄한 식별자만 허용
this.pos += 1; // [
elements = this.tryParseArrayPatternElements();
if (!elements) return null;
} else {
if (!p || p.type !== 'ident' || FORBIDDEN_KEYWORDS.has(String(p.value))) {
return null;
}
const pattern = this.tryParseArrayPattern();
if (!pattern) return null;
elements = pattern;
} else if (p && p.type === 'ident' && !FORBIDDEN_KEYWORDS.has(String(p.value))) {
name = String(p.value);
this.pos += 1;
} else {
return null;
}
let def: Node | null = null;
if (this.isPunct('=')) {
@@ -808,27 +807,30 @@ class Parser {
}
/**
* 배열 구조 분해 패턴의 요소를 파싱한다. 열림 `[` 는 호출부가 소비했고,
* 닫힘 `]` 까지 소비한다. 엘리전 홀(`[, v]`)은 null 로 표현한다.
* 중첩 패턴·rest·기본값 등 평탄한 식별자 외의 형태는 지원하지 않는다
* (레이아웃 실사용 형태가 전부 평탄 — 형태가 어긋나면 null 로 arrow 판정 자체를 되돌린다).
* 파라미터 위치의 배열 구조분해 패턴 `[a, , b]` 를 파싱한다.
* 요소는 식별자 또는 홀(elision)만 허용 — 중첩 패턴·rest·요소별 기본값은
* 레이아웃 표현식에서 쓰이지 않으므로 지원하지 않는다(발견 시 arrow 아님으로 되돌림).
*
* @return 요소 이름 배열(홀은 null), 또는 패턴 형태가 아니면 null
* @return 요소 이름 배열 (홀은 null), 패턴 형태가 아니면 null
* @since engine-v1.60.5
*/
private tryParseArrayPatternElements(): (string | null)[] | null {
private tryParseArrayPattern(): (string | null)[] | null {
const save = this.pos;
this.pos += 1; // [
const elements: (string | null)[] = [];
for (;;) {
if (this.isPunct(']')) {
this.pos += 1; // ]
this.pos += 1;
return elements;
}
if (this.isPunct(',')) {
this.pos += 1; // 엘리전 홀
elements.push(null);
elements.push(null); // 홀 (elision)
this.pos += 1;
continue;
}
const t = this.peek();
if (!t || t.type !== 'ident' || FORBIDDEN_KEYWORDS.has(String(t.value))) {
this.pos = save;
return null;
}
elements.push(String(t.value));
@@ -838,9 +840,10 @@ class Parser {
continue;
}
if (this.isPunct(']')) {
this.pos += 1; // ]
this.pos += 1;
return elements;
}
this.pos = save;
return null;
}
}
@@ -1558,18 +1561,18 @@ function bindParams(params: Param[], args: unknown[], local: Scope): void {
v = evalNode(p.default, local);
}
if (p.elements) {
// 배열 구조 분해 패턴: 홀(null)은 건너뛰고 각 이름을 인덱스 값으로 바인딩.
// 대상이 배열/문자열이 아니어도(undefined 포함) 예외 없이 undefined 바인딩 —
// 표현식 평가 실패로 화면이 통째로 비는 것보다 관대한 해석이 낫다.
const src = v as Record<number, unknown> | null | undefined;
for (let ei = 0; ei < p.elements.length; ei++) {
const name = p.elements[ei];
if (name === null) continue;
local.vars[name] = src == null ? undefined : src[ei];
// 배열 구조분해 패턴 — JS iterator 시맨틱과 동일하게 null/undefined 는 예외
if (v == null) {
throw new TypeError(`Cannot destructure ${String(v)}: value is not iterable`);
}
continue;
const arr = Array.isArray(v) ? v : Array.from(v as Iterable<unknown>);
for (let e = 0; e < p.elements.length; e++) {
const name = p.elements[e];
if (name !== null) local.vars[name] = arr[e];
}
} else if (p.name !== null) {
local.vars[p.name] = v;
}
local.vars[p.name as string] = v;
}
}
@@ -147,8 +147,69 @@ describe('SafeExpressionEvaluator', () => {
});
});
describe('arrow-function 배열 구조 분해 파라미터 (7.0.7 회귀 — 게시판 환경설정 권한 computed)', () => {
it('([key]) => — Object.entries 필터/맵 (admin_board_settings 실사용 형태)', () => {
describe('arrow param 배열 구조분해 (engine-v1.60.5 회귀 — 장바구니/바로구매 불능)', () => {
// 구 평가기(new Function)가 허용하던 형태 전수: 저장소 레이아웃 54파일 104곳 사용
// (`([code])` 35 · `([field, messages])` 34 · `([k, v])` 등 — _purchase_card.json 이 대표)
it('단일 요소 ([k])', () => {
expect(evalx('Object.entries({ a: 1, b: 2 }).map(([k]) => k)')).toEqual(['a', 'b']);
});
it('두 요소 ([k, v])', () => {
expect(evalx('Object.entries({ a: 1, b: 2 }).map(([k, v]) => k + v)')).toEqual(['a1', 'b2']);
});
it('선행 홀 ([, v])', () => {
expect(evalx('Object.entries({ a: 1, b: null }).filter(([, v]) => v != null).length')).toBe(1);
});
it('배열 인자 직접 분해', () => {
expect(evalx('[[1, 2], [3, 4]].map(([a, b]) => a * b)')).toEqual([2, 12]);
});
it('파라미터 기본값 조합 (([a, b] = []) =>)', () => {
expect(evalx('[undefined].map(([a, b] = [7, 8]) => (a ?? 0) + (b ?? 0))')).toEqual([15]);
});
it('null/undefined 인자 분해는 JS 와 동일하게 예외', () => {
expect(() => evalx('[null].map(([a]) => a)')).toThrow();
});
it('실전 회귀: _purchase_card.json 장바구니 담기 본문 표현식', () => {
const ctx = {
product: { data: { id: 98, has_options: true, options: [{ id: 1 }, { id: 2 }] } },
_local: {
selectedOptionItems: [
{
optionId: 11,
quantity: 2,
additionalOptionSelections: { 5: 50, 6: null },
additionalOptionCustomTexts: { 5: '각인 문구' },
},
],
noOptionQuantity: 1,
},
};
const expr =
'product.data?.has_options && (product.data?.options?.length ?? 0) > 1 ? ' +
'{ product_id: product.data?.id, items: (_local.selectedOptionItems ?? []).map(item => ({ ' +
'product_option_id: item.optionId, quantity: item.quantity, ' +
'additional_option_selections: Object.entries(item.additionalOptionSelections ?? {})' +
'.filter(([, vid]) => vid != null)' +
'.map(([gid, vid]) => ({ additional_option_id: Number(gid), value_id: Number(vid), custom_text: item.additionalOptionCustomTexts?.[Number(gid)] })) ' +
'})) } : { product_id: product.data?.id, items: [{ quantity: _local.noOptionQuantity ?? 1 }] }';
expect(evalx(expr, ctx)).toEqual({
product_id: 98,
items: [
{
product_option_id: 11,
quantity: 2,
additional_option_selections: [{ additional_option_id: 5, value_id: 50, custom_text: '각인 문구' }],
},
],
});
});
it('실전 회귀: 게시판 환경설정 권한 computed (filter([key]) + startsWith)', () => {
const ctx = {
settings: {
data: {
@@ -166,13 +227,7 @@ describe('SafeExpressionEvaluator', () => {
).toEqual(['read', 'write']);
});
it('([k, v]) => — 키·값 동시 바인딩', () => {
expect(evalx("Object.entries(o).map(([k, v]) => k + '=' + v).join(',')", { o: { a: 1, b: 2 } })).toBe(
'a=1,b=2',
);
});
it('([field, messages]) => — 검증 오류 표시 형태 (플러그인 설정 onError 실사용)', () => {
it('실전 회귀: 검증 오류 표시 ([field, messages]) — 플러그인 설정 onError 형태', () => {
const ctx = { errors: { name: ['이름은 필수입니다'], email: ['형식 오류'] } };
expect(evalx("Object.entries(errors ?? {}).map(([field, messages]) => field + ': ' + messages[0])", ctx)).toEqual([
'name: 이름은 필수입니다',
@@ -180,17 +235,9 @@ describe('SafeExpressionEvaluator', () => {
]);
});
it('([,v]) => — 엘리전(홀) 패턴 (_bank_management_modal 실사용)', () => {
expect(evalx('Object.entries(o).map(([,v]) => v)', { o: { a: 10, b: 20 } })).toEqual([10, 20]);
});
it('function 선언 파라미터의 배열 구조 분해', () => {
it('function 선언 파라미터의 배열 구조분해', () => {
expect(evalx('(function f([a, b]) { return a + b; })([3, 4])')).toBe(7);
});
it('구조 분해 대상이 아닌 값(undefined)은 각 이름에 undefined 바인딩', () => {
expect(evalx('[undefined].map(([a]) => a === undefined)[0]')).toBe(true);
});
});
describe('spread (array / object / call)', () => {