Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape single quote (') characters as ' #74

Closed
RyanGlScott opened this issue Sep 15, 2018 · 2 comments
Closed

Escape single quote (') characters as ' #74

RyanGlScott opened this issue Sep 15, 2018 · 2 comments

Comments

@RyanGlScott
Copy link
Contributor

RyanGlScott commented Sep 15, 2018

I was surprised to discover that the escapeXml function escapes double quotes (") but not single quotes ('). Digging into the source code of tagsoup, I found this comment:

-- | A table mapping XML entity names to resolved strings. All strings are a single character long.
-- Does /not/ include @apos@ as Internet Explorer does not know about it.
xmlEntities :: [(String, String)]
xmlEntities = let a*b = (a,[b]) in
["quot" * '"'
,"amp" * '&'
-- ,"apos" * '\'' -- Internet Explorer does not know that
,"lt" * '<'
,"gt" * '>'
]

This suggests that the reason that single quotes aren't escaped is due to Internet Explorer not supporting &apos;. But this feels a bit too conservative, since Internet Explorer does support &#39;, as suggested here. (Credit goes to this stache pull request for that idea.)

Would you be open to escapeXml escaping single quotes as &#39; instead?

@RyanGlScott RyanGlScott changed the title Escape single quote (') characters as &#39 Escape single quote (') characters as &#39; Sep 15, 2018
@ndmitchell
Copy link
Owner

Having Google'd, there doesn't seem to be a consistent set... Quite a lot do &<>, some more do &<>", others do &<>"' and some add / in there for reasons I can't fathom. I think you're right, I'd happily take a patch to make it escape ' to the numeric variant.

If this is the only function you're using in tagsoup, you may wish to consider using https://hackage.haskell.org/package/extra-1.6.9/docs/Data-List-Extra.html#v:escapeHTML instead (which also doesn't escape ', but for which I'd also happily take a patch).

@RyanGlScott
Copy link
Contributor Author

I've opened #75 and ndmitchell/extra#38 to incorporate this fix into tagsoup and extra, respectively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants