-
Notifications
You must be signed in to change notification settings - Fork 104
Open
Description
We had a case where we were setting an HTML title
attribute based on a notes field. Handlebars was correctly escaping all the dangerous characters, but left the newlines since those are valid HTML. However, when we did a diff on that code, we noticed that diff-dom
was removing the original attribute and appending pieces of the value as attributes.

We went down the rabbit hole and discovered a flaw in one regex in src/diffDOM/virtual/fromString.ts
where this regex doesn't play nicely with newlines.
const attrRE = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g
It should probably be updated to:
const attrRE = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?("[^"]*"|'[^']*')/g
I don't think this should break anything. I'm happy to put up a PR if you're OK with it.
Metadata
Metadata
Assignees
Labels
No labels