Skip to content

keep query and fragment out of copied schema source paths - #169

Merged
aizu-m merged 1 commit into
apache:trunkfrom
aizu-m:saved-filename-query-escape
Nov 23, 2026
Merged

aizu-m merged 1 commit into
apache:trunkfrom
aizu-m:saved-filename-query-escape

Conversation

@aizu-m

@aizu-m aizu-m commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

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

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@aizu-m

aizu-m commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Can i Merge ?

@aizu-m
aizu-m merged commit bc4d6ab into apache:trunk Nov 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants