WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Failed for handling entity reference HTML code #97

@conao3

Description

@conao3

When parsing HTML using hickory, converting it to hiccup, and then converting it back to HTML, the entity reference for & is processed twice, resulting in inconsistent output. Is this behavior intended?
In JavaScript, conversion is never performed twice, and the result remains consistent.

hickory/hiccup behaviour

(-> "<div>a&amp;b</div>"
    hickory.core/parse-fragment
    first
    hickory.core/as-hiccup
    hiccup2.core/html
    str)
;;=> "<div>a&amp;amp;b</div>"

javascript

const div = document.createElement('div')
div.innerHTML = "<div>a&amp;b</div>"
> '<div>a&amp;b</div>'

div.innerHTML
> '<div>a&amp;b</div>'

div.textContent
> 'a&b'

expected

(-> "<div>a&amp;b</div>"
    hickory.core/parse-fragment
    first
    hickory.core/as-hiccup
    hiccup2.core/html
    str)
;;=> "<div>a&amp;b</div>"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions