Repository navigation
Conversation
…Path variable Port of dtq-dev-93 PR 1650 (commit f08abc4). It needs the label search fix from upstream DSpace PR 11078 (PR 11075 ported to dspace-9_x), which is cherry-picked in the four commits before this one.
There was a problem hiding this comment.
🟡 Changes recommended
The search-text binding lacks regression coverage for apostrophe-containing and XPath-shaped inputs through getMatches and getBestMatch, including label- and ID-valued vocabularies and hierarchical searches.
1 open issue
What changed in this PR
This PR hardens controlled-vocabulary lookups against XPath injection by backporting search-text variable binding and applying it to node IDs.
Changes:
- Binds search text and node IDs as XPath variables instead of interpolating request values.
- Adds node-ID injection regression tests and a nested vocabulary fixture.
- Strengthens existing match assertions and includes minor code and Javadoc cleanup.
| File | Description |
|---|---|
dspace-api/src/test/java/org/dspace/content/authority/DSpaceControlledVocabularyTest.java |
Tests literal node-ID handling and strengthens match assertions. |
dspace-api/src/test/data/dspaceFolder/config/controlled-vocabularies/farm.xml |
Adds a pond child for parent/child lookup tests. |
dspace-api/src/main/java/org/dspace/content/authority/DSpaceControlledVocabulary.java |
Uses XPath variables for search text and node-ID lookups. |
Review effort: Balanced
Comment on lines
+224
to
+228
| xpath.setXPathVariableResolver(variableName -> { | ||
| String varName = variableName.getLocalPart(); | ||
| if (varName.startsWith("var")) { | ||
| int index = Integer.parseInt(varName.substring(3)); | ||
| return textHierarchy[index]; |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

References
Port of dtq-dev-93 PR 1650 (commit f08abc4). dspace-customers issue 1083, finding V4.
Upstream commits from DSpace#11078 (DSpace#11075 ported to
dspace-9_x, label search) and aa419b9 (DSpace#11964, node id).Upstream: DSpace#13386 (
dspace-9_x) and DSpace#13387 (dspace-8_x) port the same node id fix (open).Description
DSpaceControlledVocabularyput the node id and the search text from the request straight into XPath expressions, so a'could change the query. Both are now XPath variables.Instructions for Reviewers
9.1 does not have the label search fix yet (DSpace#11075, in 9.2 and later), and the dtq-dev-93 commit builds on it. So this PR has two parts:
-xand their original authors.getMatchesandgetBestMatchbind the search text as XPath variables. They applied without conflicts.getChoice,getChoicesByParentandgetParentChoiceevaluate//node[@id = $nodeId], the unusedgetNodeFromXPathis removed, and there is a new testtestNodeIdIsNotEvaluatedAsXPathwith apondnode unders40in the testfarm.xml. The diff is the same as PR 1650 and the cherry-pick had no conflicts.DSpaceControlledVocabularyTest. Locally on this branch (9.1):Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Checkstyle passes.Checklist