From 70c2fea7e6565192ebd8804b60d6230224e06212 Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 1 Apr 2026 17:53:41 +0900 Subject: [PATCH] Fix URL encoding for JSON query string parameter --- frontend/src/app/shared/services/contents.service.spec.ts | 4 ++-- frontend/src/app/shared/services/contents.service.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/shared/services/contents.service.spec.ts b/frontend/src/app/shared/services/contents.service.spec.ts index 86e6a53e0..72806f3b6 100644 --- a/frontend/src/app/shared/services/contents.service.spec.ts +++ b/frontend/src/app/shared/services/contents.service.spec.ts @@ -36,7 +36,7 @@ describe('ContentsService', () => { name: 'json query', query: { take: 17, skip: 13, query: { fullText: 'my-query' } }, requestBody: { q: sanitize({ fullText: 'my-query', take: 17, skip: 13 }) }, - requestString: `q=${JSON.stringify(sanitize({ fullText: 'my-query', take: 17, skip: 13 }))}`, + requestString: `q=${encodeURIComponent(JSON.stringify(sanitize({ fullText: 'my-query', take: 17, skip: 13 })))}`, noSlowTotal: null, noTotal: null, }, @@ -52,7 +52,7 @@ describe('ContentsService', () => { name: 'json query without total', query: { take: 17, skip: 13, query: { fullText: 'my-query' }, noTotal: true, noSlowTotal: true }, requestBody: { q: sanitize({ fullText: 'my-query', take: 17, skip: 13 }) }, - requestString: `q=${JSON.stringify(sanitize({ fullText: 'my-query', take: 17, skip: 13 }))}`, + requestString: `q=${encodeURIComponent(JSON.stringify(sanitize({ fullText: 'my-query', take: 17, skip: 13 })))}`, noSlowTotal: '1', noTotal: '1', }, diff --git a/frontend/src/app/shared/services/contents.service.ts b/frontend/src/app/shared/services/contents.service.ts index 8ca7a1ddb..aef060573 100644 --- a/frontend/src/app/shared/services/contents.service.ts +++ b/frontend/src/app/shared/services/contents.service.ts @@ -267,7 +267,7 @@ function buildFullQuery(primary: FullQuery, q?: ContentsByQuery) { function buildQueryString(input: { q?: object; odata?: string }) { const { odata, q } = input; - return q ? `?q=${JSON.stringify(q)}` : `?${odata}`; + return q ? `?q=${encodeURIComponent(JSON.stringify(q))}` : `?${odata}`; } function buildQuery(q?: ContentsByQuery): { q?: object; odata?: string } {