Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

Don't escape HTML chars inside Django tags inside attribute values #66

Merged
merged 3 commits into from
Mar 17, 2017

Conversation

rowanseymour
Copy link
Member

No description provided.

@rowanseymour rowanseymour self-assigned this Mar 17, 2017
"""
Escapes HTML entities, matching substitutions used the Ruby Haml library
Escapes HTML entities, matching substitutions used the Ruby Haml library. Entities that occur inside Django tags

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"used by"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about something like {{ foo|escape:"&" }}?

"""
Escapes HTML entities, matching substitutions used the Ruby Haml library
Escapes HTML entities, matching substitutions used the Ruby Haml library. Entities that occur inside Django tags

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about something like {{ foo|escape:"&" }}?

@rowanseymour
Copy link
Member Author

@nicpottier updated to also ignore entities inside {{ .. }} and fixed the typo

s = s.replace("'", "'")
return s
new_text = []
state = 0 # 0 = normal, 1 = in tag, 2 = in expression

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably be enum ya?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well I guess so, if we're trying to write "good code"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if only there was a pep for that

@rowanseymour rowanseymour merged commit 0fffae8 into master Mar 17, 2017
@rowanseymour rowanseymour deleted the fix_escaping branch March 17, 2017 15:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants