Repository navigation
Conversation
…XPath variable Port of dtq-dev PR 1556 (commit 612aa63).
There was a problem hiding this comment.
🟡 Changes recommended
Regression coverage is missing for search-text binding in both getMatches and getBestMatch, leaving apostrophe handling and XPath-shaped input that could broaden results unverified.
1 open issue
What changed in this PR
This PR hardens controlled-vocabulary lookups by binding request-supplied search text and node IDs as XPath variables, preventing them from changing query structure.
Changes:
- Bind search text and node IDs across search and hierarchy lookup methods.
- Add node-ID injection regression tests and a nested
pondfixture. - Clean up Javadoc and minor Java syntax.
| File | Description |
|---|---|
dspace-api/src/test/java/org/dspace/content/authority/DSpaceControlledVocabularyTest.java |
Tests literal node-ID handling and valid hierarchy lookups. |
dspace-api/src/test/data/dspaceFolder/config/controlled-vocabularies/farm.xml |
Adds pond beneath s40 for hierarchy tests. |
dspace-api/src/main/java/org/dspace/content/authority/DSpaceControlledVocabulary.java |
Replaces request-value interpolation with XPath variable binding. |
Review effort: Balanced
Comment on lines
+172
to
+176
| xpath.setXPathVariableResolver(variableName -> { | ||
| String varName = variableName.getLocalPart(); | ||
| if (varName.startsWith("var")) { | ||
| int index = Integer.parseInt(varName.substring(3)); | ||
| return textHierarchy[index].toLowerCase(); |
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 PR 1556 (commit 612aa63). dspace-customers issue 1083, finding V4.
Upstream commits ceab952 (DSpace#11075, 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
getMatchesandgetBestMatchbind the search text, andgetChoice,getChoicesByParentandgetParentChoicebind the node id as XPath variables.testNodeIdIsNotEvaluatedAsXPath. The testfarm.xmlgets apondnode unders40.DSpaceControlledVocabularyTest. Locally on this branch (7.6.1):Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Checkstyle passes.Checklist