papegaaij commented on code in PR #1880:
URL: https://github.com/apache/wicket/pull/1880#discussion_r4548985799


##########
wicket-core/src/main/java/org/apache/wicket/csp/CSPHeaderConfiguration.java:
##########
@@ -298,6 +350,8 @@ private CSPHeaderConfiguration recalculateState()
                        .flatMap(List::stream)
                        .anyMatch(value -> value == CSPDirectiveSrcValue.NONCE);
 
+               trustedTypesEnabled = contains(TRUSTED_TYPES, 
TRUSTED_TYPES_POLICY);

Review Comment:
   This only recognises the literal name `wicket`. An application that adds 
`require-trusted-types-for 'script'` and `trusted-types *` itself allows the 
policy too, but gets no meta element, so Wicket's JavaScript keeps using 
strings and breaks under enforcement. Could `*` count as allowing the policy as 
well, with a test for it?



##########
wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/MultiFileUploadField.js:
##########
@@ -158,7 +158,13 @@ function MultiSelector( eprefix, list_target, max, 
useMultipleAttr, del_label ){
                };
 
                // Set row value
-               contentsColumn.innerHTML = this.getOnlyFileNames(element);
+               var fileNames = this.getOnlyFileNamesAsArray(element);

Review Comment:
   With the option disabled this still changes behaviour: an application that 
overrides `getOnlyFileNames()` or `getOnlyFileName()` to change what the list 
shows no longer sees any effect, because `addListRow` doesn't call them anymore.
   
   Since `MultiFileUploadField` starts this script through an 
`OnDomReadyHeaderItem`, the Ajax JavaScript is always loaded, so `addListRow` 
can keep its original form and only route the markup through the policy:
   
   ```js
   contentsColumn.innerHTML = 
Wicket.TrustedTypes.html(this.getOnlyFileNames(element));
   ```
   
   With the option disabled, `html()` returns its input, so nothing changes. 
With it enabled, the markup is the escaped output of `getOnlyFileName()`. That 
makes `getOnlyFileNamesAsArray()`, the two deprecations and the section in 
`migration-to-12.md` unnecessary, and the tests for `addListRow` can go back to 
checking the escaped markup.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to