aizu-m opened a new pull request, #169: URL: https://github.com/apache/poi-xmlbeans/pull/169
Found while reading how the schema compiler names the copies it writes under `<classes>/org/apache/xmlbeans/metadata/src`. 1. `StscState.relativize(uri, true)` returns `URI.relativize(...).toString()` as is when the schema is under the base dir. `relativize` normalises the path but not the query or fragment, so `b.xsd?x=/../../x.xsd` keeps its `/..` segments. 2. `StscImporter.copySchemaSource` writes to `new File(schemasDir, name)`. An include of `b.xsd?x=/c.xsd` creates the `b.xsd?x=` directory. A second include of `b.xsd?x=/../../../../../../../../escaped/pwned.xsd` then writes the bytes of `b.xsd` to `<out>/escaped/pwned.xsd`. File URLs ignore the query, so `b.xsd` opens and no download flag is needed. Reproduced through `SchemaCompiler.compile` (scomp, Maven plugin). 3. The absolute-URI branch of the same method already hexsafes the query. The relative branch now keeps the normalised raw path and hexsafes the query/fragment suffix. Display names and URIs without a query or fragment are unchanged. Observed: `StscStateSavedFilenameTest` fails before the change (the file lands outside the schemas dir) and passes after. `./gradlew test` is green (3333 tests). -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
