Skip to content

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

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

jr-rk wants to merge 1 commit into
customer/jcufrom
jcu/be-vocabulary-xpath-variable

Conversation

@jr-rk

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

Copy link
Copy Markdown

References

Port of dtq-dev-93 PR 1650 (commit f08abc4). dspace-customers issue 1083, finding V4.
Upstream commit aa419b9 (DSpace#11964).
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 from the request straight into the XPath expression, so a ' could change the query. The id is now the XPath variable $nodeId. The label search already uses XPath variables on 9.3 (DSpace#11075).

Instructions for Reviewers

  • getChoice, getChoicesByParent and getParentChoice evaluate //node[@id = $nodeId] with an XPathVariableResolver.
  • The unused getNodeFromXPath is removed.
  • New test testNodeIdIsNotEvaluatedAsXPath. The test farm.xml gets a pond node under s40.
  • The diff is the same as dtq-dev-93 PR 1650. The cherry-pick had no conflicts.
  • Tests: DSpaceControlledVocabularyTest. Locally on this branch (9.3): Tests run: 8, 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.

🟢 Approval recommended

No active review issues remain for the change to bind request-supplied node IDs as XPath variables.

No open issues 🎉

What changed in this PR

This PR hardens controlled-vocabulary lookups against XPath injection by binding request-supplied node IDs as variables instead of inserting them into expressions.

Changes:

  • Uses $nodeId binding for choice, child, and parent lookups, replacing the old XPath helper.
  • Adds regression coverage for injection attempts and valid hierarchy lookups.
  • Adds a nested pond node to the test vocabulary.
File Description
dspace-api/​src/​test/​java/​org/​dspace/​content/​authority/​DSpaceControlledVocabularyTest.java Tests literal node-ID handling and valid parent/child results.
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 Binds node IDs through XPath variable resolvers.

Review effort: Balanced

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