Review main Work in progress

98319[BUGFIX] Handle query parameters of links in one place

Matthias Vogel CR 0 V 0 Hard +435 −20 updated 12/04/26, 10:25

Commit message

Three places in the core add, replace or remove one parameter in the
query of an address. Each place has its own code for this task:

* WorkspacePreview builds the links in the info box of a workspace
  preview: to the page without the preview and to the live version
  of the page. It also builds the link back to the page in the
  logout message. It parses the query and builds it again.
* AbstractContentSecurityPolicyReporter::anonymizeUri() removes the
  parameter "token" from the addresses in a CSP report. It also
  parses the query and builds it again.
* EditDocumentController appends "columnsOnly=" as a string to the
  query of the link of the button "Edit whole record".

A parsed and rebuilt query loses data. In the links of the workspace
preview, a repeated name ("tag=1&tag=2") lost all values but the
last one, "tag[]=1&tag[]=2" lost one value, and "+" (a space) became
"%2B" (a plus sign). The page then got other parameters, for example
a search page showed other results.

The new internal class QueryParameterReplacer (TYPO3\CMS\Core\Http)
is now the one place for this task. It adds, replaces or removes one
parameter and keeps every other byte of the query. A pair counts by
the name that PHP reads from it, because the site reads the query in
the same way. The three places above use this class now. Thus the
links of the workspace preview keep the query of the page address.

The CSP report now keeps the query of an address as the browser sent
it. Before, "a.b=1" became "a_b=1", "flag" became "flag=", and a
repeated name ("tag=1&tag=2") kept only the last value. This change
is visible in the backend module "Content Security Policy". The
summary of a report is calculated from the blocked address. Thus a
new report for a blocked address with such a query can get a
different summary, and the module shows it apart from older reports
for the same address. The token is removed as before, also with a
name like "token[]", " token" or "tok%65n".

The link of the button "Edit whole record" had the list of fields
("columnsOnly[tt_content][0]=header") and an empty "columnsOnly" after
it. PHP read only the last one. The link now has only the empty
parameter.

GuzzleHttp\Psr7\Uri::withoutQueryValue() is not used. It compares
the decoded names only. Thus a parameter like "ADMCMD_prev[]" or
"ADMCMD.prev" stays in the address, although the site reads it as
"ADMCMD_prev". It also needs a URI object, which changes the bytes
of an address as it is written in a link, a form or a redirect.
HttpUtility::buildQueryString() builds a query from an array. Thus
it loses the same data as a parsed and rebuilt query.

Three later patches of the preview token series use the class:

* "Issue preview tokens in the backend" removes "ADMCMD_prev" and an
  older token from the preview address and adds the new token
  (withoutParameter(), withParameter()).
* "Accept preview tokens in the frontend" removes the token from an
  address as it is written (removeFromUrl()). It does this in a
  redirect to an address outside the preview, and in the redirect
  that takes the token out of the address bar. Its test adds a
  token to an address with replaceInUrl().
* "Keep the preview token in links, forms and redirects" is the first
  code that uses replaceInUrl(). PreviewTokenKeeper::keepInUrl() puts
  the token into the links, forms and redirects of a preview.

The test of the logout link leaves out a list in brackets
("tag[]=1&tag[]=2") until change 98199 (#111661) is merged, which
can happen before or after this change.
Show more Show less
Resolves: #TBD
Related: #110664
Related: #111661
Releases: main, 14.3
Change-Id: I1eb9007e2a458e7e381df65a75853a5df0952407

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 1
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/19/98319/1 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/19/98319/1 && git cherry-pick FETCH_HEAD

Review

  • Code review CR 0 Needs a vote
  • Verified V 0 Needs a vote
    • core-ci +1 CI

Relation chain 16

  1. 98329[BUGFIX] Use preview tokens in the frames of the workspace preview Based on this change Matthias Vogel → main, 14.3 Hard +580 −55 CR 0 V 0 Work in progress Merge conflict
  2. 98328[TASK] Add a live view kind of preview token Based on this change Matthias Vogel → main, 14.3 Hard +771 −73 CR 0 V 0 Work in progress Merge conflict
  3. 98327[BUGFIX] Follow the page of the preview frame in the backend Based on this change Matthias Vogel → main, 14.3 Expert +1225 −114 CR 0 V -1 Work in progress Merge conflict
  4. 98326[BUGFIX] Keep the preview token in navigations that scripts start Based on this change Matthias Vogel → main, 14.3 Hard +922 −4 CR 0 V 0 Work in progress Merge conflict
  5. 98325[BUGFIX] Keep the preview token in links, forms and redirects Based on this change Matthias Vogel → main, 14.3 Hard +828 −38 CR 0 V 0 Work in progress Merge conflict
  6. 98324[BUGFIX] Renew the preview token of the frame Based on this change Matthias Vogel → main, 14.3 Expert +1634 −63 CR 0 V 0 Work in progress Merge conflict
  7. 98323[TASK] Add one frame component for the preview frames of the backend Based on this change Matthias Vogel → main, 14.3 Hard +544 −68 CR 0 V 0 Work in progress Merge conflict
  8. 97235[BUGFIX] Preview hidden pages across site domains Based on this change Matthias Vogel → main, 14.3 Hard +467 −10 CR 0 V 0 Work in progress Merge conflict 19 unresolved
  9. 98322[TASK] Accept preview tokens in the frontend Based on this change Matthias Vogel → main, 14.3 Expert +1994 −4 CR 0 V 0 Work in progress Merge conflict
  10. 98321[TASK] Issue preview tokens in the backend Based on this change Matthias Vogel → main, 14.3 Hard +880 −1 CR 0 V 0 Work in progress Merge conflict
  11. 98320[TASK] Check where a request with a preview token comes from Based on this change Matthias Vogel → main, 14.3 Hard +934 −1 CR 0 V 0 Work in progress Merge conflict
  12. 98319 [BUGFIX] Handle query parameters of links in one place This change

  13. 98318[TASK] Resolve the sites and hosts a backend user may preview This change is based on it Matthias Vogel → main, 14.3 Hard +700 −0 CR 0 V 0 Work in progress
  14. 98317[TASK] Sign and verify preview tokens This change is based on it Matthias Vogel → main, 14.3 Hard +625 −0 CR 0 V -1 Work in progress Merge conflict
  15. 98316[TASK] Add typed claims for preview tokens This change is based on it Matthias Vogel → main, 14.3 Hard +530 −0 CR 0 V -1 Work in progress
  16. 98315[TASK] Add a read-only backend user for one workspace This change is based on it Matthias Vogel → main, 14.3 Expert +1719 −2 CR 0 V 0 Work in progress

    The chain has patch set 1 of 2, the changes above it need a rebase.

Merge conflicts 15

Show 10 more changes Show less

Issues 2

Files 9

Review log 23

  1. Matthias Vogel uploaded patch set 1 12/04/26, 09:02

  2. core-ci voted on patch set 1 V +1 12/04/26, 09:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/116303

  3. Matthias Vogel wrote 12/04/26, 10:25

    Topic set to cross-domain-preview