tbranyen/diffhtml

Entities decoding goes haywire for input values

mderijcke opened this issue · 3 comments

Hi there,

We had an input like this:

<input value="T-tag pafssageeapos;s [Month] [Year] &lt;b&gt;test&lt;/b&gt;">

That should have looked like:

T-tag pafssagee's [Month] [Year] <b>test</b>

But ended up looking like:

T-tag pafssageeapos;s [Month] [Year] &lt;b&gt;test&lt;/b&gt;

DiffHTML seems to (double) encode the ampersands, which it has no business in doing. I fixed it this way:

diff.addTransitionState("attributeChanged", (element, attributeName, oldValue, newValue) => {
    if (attributeName === "value") {
        $(element).val(entities.decodeHTML(newValue))
    }
})

But I have a strong feeling this isn't intended behavior. Maybe something to look into?

Absolutely, this is not good business. I'll fix it up and let you know once a new patch release is out.

@mderijcke can you test #93 and let me know if it fixes your issue? You can test by using npm to install that commit. if you aren't sure how:

npm install tbranyen/diffhtml#fix-decoding-issue

Fixed and published in v0.9.2