Skip to content

HTML entities are not being preserved #37

Open

Description

@cimmanon

All HTML entities found in my templates are being converted to the actual character (eg. & becomes &, © becomes ©). For most characters, this doesn't matter a whole lot, but a raw ampersand causes HTML validation to fail.

Template source:

<p class="copyright">&copy;2013 Company Name here</p>

Rendered document's source:

<p class='copyright'>©2013 Company Name here</p>

Activity

  1. cdsmith commented on Nov 1, 2013

    @cdsmith
    Member

    For the copyright symbol, this is expected behavior. The entity is
    unnecessary as long as you're working in UTF-8 or another good enough
    character set.

    This is probably incorrect if it's happening for &. Are you sure it is?
    Or just speculating?
    On Oct 31, 2013 7:55 AM, "cimmanon" notifications@github.com wrote:

    All HTML entities found in my templates are being converted to the actual
    character (eg. & becomes &, © becomes ©). For most characters,
    this doesn't matter a whole lot, but a raw ampersand causes HTML validation
    to fail.

    Template source:

    ©2013 Company Name here

    Rendered document's source:

    ©2013 Company Name here

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/37
    .

  2. mightybyte commented on Nov 1, 2013

    @mightybyte
    Member

    I just checked and it looks like it is indeed happening for &.

  3. mightybyte commented on Mar 27, 2016

    @mightybyte
    Member

    @cdsmith Any idea where this might be in xmlhtml?

  4. cdsmith commented on Mar 30, 2016

    @cdsmith
    Member

    https://github.com/snapframework/xmlhtml/blob/master/src/Text/XmlHtml/HTML/Render.hs#L60

    Currently, it seems that the '&' character is only escaped when it is an "ambiguous ampersand", as defined at https://www.w3.org/TR/html5/syntax.html#text Non-ambiguous ampersands should not cause HTML validation to fail. I believe there is a reason this is done in this way, and I think it has something to do with certain browsers not liking the escaping of & inside a URL. I don't recall the details.

  5. mightybyte commented on Aug 17, 2016

    @mightybyte
    Member

    Hmmm, I can't decide what to do on this issue. The existing behavior appears to be correct, but on the other hand maybe a few unnecessary entities are tolerable if they are causing validation problems. I think I'm leaning slightly more towards closing this issue and leaving things as-is, but I could certainly be persuaded otherwise. Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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