Skip to content

Fix a markup parser crash when a tag name shadows hasOwnProperty - #9468

Merged
willeastcott merged 2 commits into
mainfrom
fix-markup-hasownproperty-crash
Sep 20, 2026
Merged

willeastcott merged 2 commits into
mainfrom
fix-markup-hasownproperty-crash

Conversation

@willeastcott

Copy link
Copy Markdown
Contributor

Fixes the crash reported in #8578 with the minimal change.

The markup parser stores tag names as keys on plain objects and then calls .hasOwnProperty on those same objects while merging overlapping tags. A text element with enableMarkup set and text containing a tag named hasOwnProperty shadows the method and the parser throws:

TypeError: source.hasOwnProperty is not a function

This replaces the four method calls in markup.js with Object.prototype.hasOwnProperty.call(...) via a module-level hasOwn constant, and adds a Markup test file that covers the shadowing case and confirms Object.prototype is not polluted by a [__proto__] tag. The shadowing tests fail against the unmodified parser and pass with the change.

Unlike #8578, this does not touch the core extend utility or its merge semantics. The [__proto__] case was never a pollution vector: the tag is silently dropped both before and after this change.

🤖 Generated with Claude Code

The markup parser stores tag names as keys on plain objects, then calls
`.hasOwnProperty` on those objects while merging. A tag named
`[hasOwnProperty]` shadows the method and the parser throws a TypeError.
Call `Object.prototype.hasOwnProperty` directly instead.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Build size report

This PR changes the size of the minified bundles.

Bundle Minified Gzip Brotli
playcanvas.min.js 2472.0 KB (+9 B, +0.00%) 637.0 KB (+28 B, +0.00%) 494.3 KB (−538 B, −0.11%)
playcanvas.min.mjs 2469.3 KB (+7 B, +0.00%) 635.5 KB (+38 B, +0.01%) 494.1 KB (+182 B, +0.04%)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The change is minimal, targeted to the reported failure mode, and is backed by regression tests covering the crash scenario.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

This pull request fixes a crash in the Element markup parser when a user-defined tag name shadows Object.prototype.hasOwnProperty (e.g. [hasOwnProperty]...[/hasOwnProperty]). It does so by switching internal own-property checks to Object.prototype.hasOwnProperty.call(...) (via a module-level hasOwn reference) and adds a focused unit test suite covering the shadowing case and a __proto__ non-pollution check.

Changes:

  • Replace direct .hasOwnProperty(...) calls in markup.js with hasOwn.call(obj, key) to avoid shadowing crashes.
  • Add Markup unit tests for tag-stripping and for handling a hasOwnProperty tag name without throwing.
  • Add a regression test ensuring __proto__ tags do not pollute Object.prototype.
File Description
src/​framework/​components/​element/​markup.js Hardens internal merging/edge-building logic against hasOwnProperty shadowing by using hasOwn.call(...).
test/​framework/​components/​element/​markup.test.mjs Adds unit coverage for the reported crash scenario and a __proto__ non-pollution regression check.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread test/framework/components/element/markup.test.mjs
Exercises the target-side own-property check in the markup merge helper.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@willeastcott
willeastcott merged commit 107c60e into main Sep 20, 2026
10 checks passed
@willeastcott
willeastcott deleted the fix-markup-hasownproperty-crash branch September 20, 2026 18:31

This branch was successfully deployed

2 active deployments
Preview – engine — 2bf7f5f2 Deployed Sep 20, 2026 by vercel[bot]
Preview – engine-api-docs — 2bf7f5f2 Deployed Sep 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants