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

Added in default encoding and new raw prop. #24

Merged
merged 6 commits into from
May 23, 2014
Merged

Added in default encoding and new raw prop. #24

merged 6 commits into from
May 23, 2014

Conversation

tbranyen
Copy link
Owner

The default encoding for properties will be be encoded to help alleviate
issues arising from XSS attacks.

If you wish to avoid this inconvience in your code, you can use the new
triple curley bracket notation to render the raw property:

{{{ rawProperty }}}

The default encoding for properties will be be encoded to help alleviate
issues arising from XSS attacks.

If you wish to avoid this inconvience in your code, you can use the new
triple curley bracket notation to render the raw property:

    {{{ rawProperty }}}
@tbranyen
Copy link
Owner Author

Finally :)

tbranyen added a commit that referenced this pull request May 23, 2014
Added in default encoding and new raw prop.
@tbranyen tbranyen merged commit b1e9af4 into master May 23, 2014
@tbranyen tbranyen deleted the encoding branch May 23, 2014 05:01
}

// Identifies all characters in the unicode range: 00A0-9999, ampersands,
// greater & less than) with their respective html entity.

Choose a reason for hiding this comment

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

Why stop at U+9999?

Choose a reason for hiding this comment

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

If you just want to escape unsafe characters, just escaping &, <, ", ', and possibly > and ``` (if you want to support unquoted attribute values and HTML comments) is enough for HTML contexts. This is what _.escape and `he.escape()` do, btw.

If you want to encode all non-ASCII symbols as well, use something like he.encode().

What you’re doing now seems like something in between. What is the goal exactly?

Choose a reason for hiding this comment

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

Note that the current approach returns incorrect results because it doesn’t account for http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#table-charref-overrides.

(It leaves astral symbols/surrogates alone as the range doesn’t match them; so it bypasses that issue.)

Posted some more info here: http://stackoverflow.com/a/23831239/96656

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