Skip to content

TUL/Fix dspace-customers 1083 V4: bind vocabulary node id as an XPath variable - #1766

Draft
jr-rk wants to merge 1 commit into
customer/TULfrom
tul/be-vocabulary-xpath-variable
Draft

jr-rk wants to merge 1 commit into
customer/TULfrom
tul/be-vocabulary-xpath-variable

Conversation

@jr-rk

@jr-rk jr-rk commented Nov 26, 2026

Copy link
Copy Markdown

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

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

  • getMatches and getBestMatch bind the search text, and getChoice, getChoicesByParent and getParentChoice bind the node id as XPath variables.
  • New test testNodeIdIsNotEvaluatedAsXPath. The test farm.xml gets a pond node under s40.
  • The diff is the same as dtq-dev PR 1556. The cherry-pick had no conflicts.
  • Tests: DSpaceControlledVocabularyTest. Locally on this branch (7.5): Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Checkstyle passes.

Checklist

  • My PR is created against the branch it ports to
  • My PR is small in size
  • My PR follows the code conventions and passes Checkstyle
  • My PR includes Javadoc for the new public methods
  • My PR passes all tests and includes new or updated tests
  • My PR includes details on how to test it
  • No new dependencies, no REST contract change, no new configuration

@jr-rk jr-rk self-assigned this Nov 26, 2026
@jr-rk
jr-rk requested a balanced review from Copilot November 26, 2026 09:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new label-search variable binding lacks regression coverage for apostrophes, XPath-like input, and multi-segment lookups in both search and getBestMatch.

1 open issue
What changed in this PR

This PR hardens controlled-vocabulary lookups by binding request values as XPath variables rather than inserting them into expressions.

Changes:

  • Bind search text and node IDs in vocabulary searches and hierarchy lookups.
  • Add node-ID injection regression tests and a nested pond fixture.
  • Apply minor Java and Javadoc cleanup.
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 under s40 for hierarchy tests.
dspace-api/​src/​main/​java/​org/​dspace/​content/​authority/​DSpaceControlledVocabulary.java Replaces interpolated request values 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

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