davsclaus opened a new pull request, #30591:
URL: https://github.com/apache/camel/pull/30591

   [CAMEL-27380](https://issues.apache.org/jira/browse/CAMEL-27380)
   
   Since CAMEL-24451 (4.23) the runtime `document()` function honours the 
transformer factory's `ACCESS_EXTERNAL_STYLESHEET` protocols, which 
`xslt-saxon` sets to deny-all. Saxon reads the resources of the XSLT 3.0 
functions `unparsed-text()`, `unparsed-text-lines()`, 
`unparsed-text-available()` and `json-doc()` through its 
`UnparsedTextURIResolver` instead, which resolves against the unrestricted 
resolver used for stylesheet compilation, so these functions still read 
external `file:` and `http:` resources.
   
   ## Changes
   
   - `XsltSaxonBuilder` installs a `RestrictedUnparsedTextResolver` at the 
first transform: an external `http`/`https`/`ftp`/`file` URI that the factory 
does not permit fails with `FOUT1170` (logged as a WARN, as for `document()`); 
other URIs go to the resolver Saxon would have used.
   - Only when Camel's `XsltUriResolver` is in use and the allowed protocols 
are restricted (read from Saxon's `Feature.ALLOWED_PROTOCOLS`, which is what 
the factory attribute maps to), the same conditions as CAMEL-24451. A factory 
that permits the protocols, or `all`, is unaffected.
   - Installed on the Saxon configuration and on the current controller, so a 
transformer reset for reuse and a stylesheet run with `fn:transform()` are 
covered too.
   - `xsl:include` / `xsl:import`, and Camel's `classpath:`, `ref:` and `bean:` 
schemes are unaffected. `collection()` and `uri-collection()` were already 
restricted by Saxon itself.
   - xslt-saxon component page: a note on what is refused at transform time and 
how to permit protocols; catalog copy updated. Upgrade guide entry for 4.24.
   
   ## Tests
   
   - `XsltSaxonResourceFunctionsExternalAccessTest` (10 tests, through a 
stylesheet with a classpath `xsl:include`): by default a `file:` resource is 
refused for `unparsed-text`, `unparsed-text-lines`, `json-doc`, `collection` 
and via `fn:transform`, and `unparsed-text-available` returns false; with a 
factory permitting `file` or `all` every function reads it; `classpath:` 
`unparsed-text` still works.
   - camel-xslt-saxon: 87 tests, 0 failures.
   
   Note: with `contentCache=false` the stylesheet is recompiled after the first 
transform, so an `unparsed-text()` of an external URI evaluated at compile time 
(`use-when`, static params) would then be refused too.
   
   _Claude Code on behalf of Claus Ibsen_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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