Skip to content

Commit 9b3ee09

Browse files
pixeldesubnf
authored andcommitted
[TASK] Use UrlFactory for query generation in AjaxRequest
Switching the implementations here because InputTransformer decodes properly encoded query arguments. Resolves: #108052 Related: #107475 Releases: main Change-Id: Ice2256db1260b90844d3efa812d0cd7d99aa33ce Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/91548 Reviewed-by: Garvin Hicking <garvin@hick.ing> Tested-by: core-ci <typo3@b13.com> Reviewed-by: Benjamin Franzke <ben@bnf.dev> Tested-by: Benjamin Franzke <ben@bnf.dev> Tested-by: Garvin Hicking <garvin@hick.ing>
1 parent d1af61b commit 9b3ee09

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

Build/Sources/TypeScript/backend/form-engine-link-browser-adapter.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,9 @@ export default (function() {
7272
const attributeValues = LinkBrowser.getLinkAttributeValues();
7373
// encode link on server
7474
attributeValues.url = input;
75-
const searchParams = new URLSearchParams();
76-
for (const [key, value] of Object.entries(attributeValues)) {
77-
searchParams.set(key, value);
78-
}
7975

8076
(new AjaxRequest(TYPO3.settings.ajaxUrls.link_browser_encodetypolink))
81-
.withQueryArguments(searchParams)
77+
.withQueryArguments(attributeValues)
8278
.get()
8379
.then(async (response: AjaxResponse): Promise<void> => {
8480
const data: Response = await response.resolve();

Build/Sources/TypeScript/core/ajax/ajax-request.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import { AjaxResponse } from '@typo3/core/ajax/ajax-response';
1515
import { InputTransformer, type GenericKeyValue } from './input-transformer';
1616
import type { RequestMiddleware, RequestHandler } from '@typo3/core/ajax/ajax-request-types';
17+
import { UrlFactory } from '@typo3/core/factory/url-factory';
1718

1819
/**
1920
* @example send data as `Content-Type: multipart/form-data` (default)
@@ -54,8 +55,10 @@ class AjaxRequest {
5455
public withQueryArguments(data: string | Array<string> | GenericKeyValue | URLSearchParams): AjaxRequest {
5556
const clone = this.clone();
5657

57-
if (!(data instanceof URLSearchParams)) {
58-
data = new URLSearchParams(InputTransformer.toSearchParams(data));
58+
if (Array.isArray(data)) {
59+
data = new URLSearchParams(data.join('&'));
60+
} else if (!(data instanceof URLSearchParams)) {
61+
data = UrlFactory.createSearchParams(data);
5962
}
6063
for (const [key, value] of data.entries()) {
6164
this.url.searchParams.append(key, value);

typo3/sysext/backend/Resources/Public/JavaScript/form-engine-link-browser-adapter.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typo3/sysext/core/Resources/Public/JavaScript/ajax/ajax-request.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)