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_html: stop encoding slash, change apostrophe encoding to ', better docs #662

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chris-morgan
Copy link

More details in the commit message.

I propose this as an alternative to #568; I wrote it before checking if someone had already done much the same thing (or else I would probably not have bothered—though I also have a vague feeling that I knew about #568 last year but have forgotten about it since), but I think my patch is more thorough.

I also propose that this shouldn’t be considered a breaking change; anything that depended on slash being escaped as / was already catastrophically wrong; if you want to compare equality of serialised HTML (a very dubious operation in general, tests are the only place I’d even consider countenancing it), you need to normalise it first to be correct. I suppose this is the main argument against performing this change in a minor or patch release: you may break some tests, whether you consider those tests Incorrect-with-a-capital-I or not. After writing this out I guess I’m more sympathetic to the breaking-change classification, though I’m still fed up with gratuitously mangled URLs! 🙂

/cc @89z

The OWASP XSS cheat sheet is a very badly-written document that hasn’t
been maintained and still contains various errors that have lasted more
than a decade, in some cases despite them being pointed out. Also the
section being quoted here was being misapplied anyway (it’s only for
*text*, not for attribute values, and it therefore escapes *way* more
than is needed). The entire document urgently needs to be completely
rewritten, but they’re not doing it. Hence in part my removal of any
citation of it.

One recently exorcised ancient error is the recommendation to escape
slashes: <OWASP/CheatSheetSeries#515>. That
was *always* spurious, and I want it gone partly under the principle of
least encoding but mostly because I’m fed up with URLs being uglified in
this way.

I’ve also changed the escaping of ' from &#x27; to &apos;, because the
reason for avoiding &apos; is invalid (it was an accidental omission in
an early HTML5 spec, long since reinstated, and all user agents always
supported it).
@chris-morgan chris-morgan changed the title escape_html: stop encoding slash, change apostrophy encoding to &apos;, better docs escape_html: stop encoding slash, change apostrophe encoding to &apos;, better docs Aug 25, 2021
@Keats
Copy link
Owner

Keats commented Aug 28, 2021

It hasn't been ignored though? Just that it will be merged for a future major version as it's breaking imo.
When a behaviour is specifically indicated in the docs, changing it is a breaking change.

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

Successfully merging this pull request may close these issues.

2 participants