Bug Tracker

Ticket #6779 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

Dom Manipulation fails if added text happens to match Object method

Reported by: cscott Owned by: dmethvin
Priority: high Milestone:
Component: manipulation Version: 1.4.4
Keywords: dommanip cache Cc:
Blocking: Blocked by: #5876

Description

When you try to add the text "hasOwnProperty", for example, the dom manipulation cache "finds" hasOwnProperty and tries to add a *function* to the DOM. This also holds for any other methods of Object.

The attached patch fixes the problem, by using hasOwnProperty to ensure that the cache match isn't actually an Object method. (We also need to ensure that hasOwnProperty isn't cacheable.)

Attachments

0001-Avoid-problems-when-adding-text-which-happens-to-mat.patch Download (1.4 KB) - added by cscott 4 years ago.
Patch to fix the problem.

Change History

Changed 4 years ago by cscott

Patch to fix the problem.

comment:2 Changed 4 years ago by rwaldron

  • Owner set to cscott
  • Priority set to undecided
  • Status changed from new to pending

Please provide a reduced jsFiddle test case, thanks!

comment:3 Changed 4 years ago by dmethvin

comment:4 Changed 4 years ago by dmethvin

snover suggested we just not cache strings that have no html, that would fix the problem with a simple test for '<'.

comment:5 Changed 4 years ago by snover

  • Priority changed from undecided to high
  • Status changed from pending to open
  • Version changed from 1.4.2 to 1.4.4
  • Blocked by 5876 added
  • Milestone 1.4.3 deleted

Beyond just not testing for strings with no HTML, I suggested to only cache strings where the first character is a <.

comment:6 Changed 4 years ago by snover

  • Keywords dommanip cache added

comment:7 Changed 4 years ago by dmethvin

  • Owner changed from cscott to dmethvin
  • Status changed from open to assigned

comment:9 Changed 4 years ago by Dave Methvin

  • Status changed from assigned to closed
  • Resolution set to fixed

Don't cache non-html strings in buildFragment to avoid possible collision with the names of Object methods like toString. Also makes the unit tests 0.5% to 8% faster. Fixes #6779.

Changeset: 5fd21fc02bda43d4e31bcf2d5b55b918a9190a7f

comment:10 Changed 4 years ago by Dave Methvin

Don't cache non-html strings in buildFragment to avoid possible collision with the names of Object methods like toString. Also makes the unit tests 0.5% to 8% faster. Fixes #6779.

Changeset: 5fd21fc02bda43d4e31bcf2d5b55b918a9190a7f

Note: See TracTickets for help on using tickets.