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


##########
wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js:
##########
@@ -229,6 +229,79 @@
                }
        };
 
+       /**
+        * Trusted Types
+        *
+        * A page with the Content-Security-Policy "require-trusted-types-for 
'script'" accepts no
+        * strings at DOM sinks such as innerHTML. Wicket trusts the markup and 
the scripts of an Ajax
+        * response, so the policy 'wicket' passes them on unchanged. They stay 
strings where the
+        * browser has no Trusted Types or the page does not allow the policy.
+        */
+       Wicket.TrustedTypes = (function () {
+               const identity = function (value) {
+                       return value;
+               };
+               let policy;
+
+               const getPolicy = function () {
+                       if (!policy) {
+                               policy = { createHTML: identity, createScript: 
identity, createScriptURL: identity };
+                               if (window.trustedTypes && 
window.trustedTypes.createPolicy) {
+                                       try {
+                                               policy = 
window.trustedTypes.createPolicy('wicket', policy);

Review Comment:
   Done in afcb17a: the server renders `<meta name="wicket-trusted-types">` 
only when a CSP header allows the `wicket` policy. Without it neither engine 
creates a policy, `html()`, `script()` and `scriptURL()` return their input, 
and the `text xml` converter is not installed.
   



-- 
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