Skip to content

fix: Improve target option processing in js.js#41729

Open
odaysec wants to merge 1 commit into
owncloud:masterfrom
odaysec:patch-1
Open

fix: Improve target option processing in js.js#41729
odaysec wants to merge 1 commit into
owncloud:masterfrom
odaysec:patch-1

Conversation

@odaysec

@odaysec odaysec commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Refactor target option handling to avoid HTML parsing. fix is to avoid passing potentially untrusted values directly to $() in the fallback branch. Keep selector strings handled via $(document).find(...), and for non-string values only pass through safe object types (DOM node, window/document, jQuery object, event target). If an unexpected value is provided, resolve to an empty jQuery set instead of invoking $() on it.

In core/js/js.js, update the target initialization around lines 2669–2672. Replace the current ternary with a small IIFE that:

  • uses $( document ).find( options.of ) for string selectors,
  • uses options.of.target for event objects (if present),
  • accepts jQuery objects and DOM-like objects directly,
  • otherwise returns $().

Description

Related Issue

  • Fixes <issue_link>

Motivation and Context

How Has This Been Tested?

  • test environment:
  • test case 1:
  • test case 2:
  • ...

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Database schema changes (next release will require increase of minor version instead of patch)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:
  • Changelog item, see TEMPLATE

Refactor target option handling to avoid HTML parsing. fix is to avoid passing potentially untrusted values directly to `$()` in the fallback branch. Keep selector strings handled via `$(document).find(...)`, and for non-string values only pass through safe object types (DOM node, window/document, jQuery object, event target). If an unexpected value is provided, resolve to an empty jQuery set instead of invoking `$()` on it.

In `core/js/js.js`, update the `target` initialization around lines 2669–2672. Replace the current ternary with a small IIFE that:
- uses `$( document ).find( options.of )` for string selectors,
- uses `options.of.target` for event objects (if present),
- accepts jQuery objects and DOM-like objects directly,
- otherwise returns `$()`.
@odaysec
odaysec requested a review from a team as a code owner July 25, 2026 21:11
@update-docs

update-docs Bot commented Jul 25, 2026

Copy link
Copy Markdown

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

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.

1 participant