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

Auto-closing <a/> tags not closed #8

Closed
isaacs opened this issue Oct 13, 2012 · 2 comments
Closed

Auto-closing <a/> tags not closed #8

isaacs opened this issue Oct 13, 2012 · 2 comments

Comments

@isaacs
Copy link

isaacs commented Oct 13, 2012

Stuff like this makes problems:

<p><a name="foo"/> This is the foo section.</p>
<p><a name="bar"/> This is the bar section.</p>

Sanitized result:

<p><a name="foo"> This is the foo section.
<p><a name="bar"> This is the bar section.</a></p></a></p>
@isaacs
Copy link
Author

isaacs commented Oct 13, 2012

Somewhat ugly workaround:

function sanitize(p, urlPolicy) {
  p = p.replace(/<([a-zA-Z]+)([^>]*)\/>/g, '<$1$2></$1>')
  return sanitizer.sanitize(p, urlPolicy)
}

EDIT: Updated, because actually no auto-closed tags are handled properly.

@theSmaw
Copy link
Owner

theSmaw commented Oct 19, 2013

Awesome. I've brought this fix into 0.1.1:

it('should sanitize auto-closing tags', function() {
    assert.equal('<p><a name="p-foo"></a> This is the foo section.</p><p><a name="p-bar"></a> This is the bar section.</p>', sanitizer.sanitize('<p><a name="foo"/> This is the foo section.</p><p><a name="bar"/> This is the bar section.</p>', uriPolicy, nmTokenPolicy));
});

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