spaCy/spacy/tests/regression/test_issue2361.py
ansgar-t 9732988951 escape html in displacy.render (#2378) (closes #2361)
## Description
Fix for issue #2361 :
replace &, <, >, " with &amp;amp; , &amp;lt; , &amp;gt; , &amp;quot; in before rendering svg

## Checklist
<!--- Before you submit the PR, go over this checklist and make sure you can
tick off all the boxes. [] -> [x] -->
- [x] I have submitted the spaCy Contributor Agreement.
- [ ] I ran the tests, and all new and existing tests passed.
(As discussed in the comments to #2361)
- [x] My changes don't require a change to the documentation, or if they do, I've added all required information.
2018-05-28 18:36:41 +02:00

15 lines
361 B
Python

from __future__ import unicode_literals
import pytest
from ...displacy import render
from ..util import get_doc
def test_issue2361(de_tokenizer):
tokens = de_tokenizer('< > & " ')
html = render(get_doc(tokens.vocab, [t.text for t in tokens]))
assert '&lt;' in html
assert '&gt;' in html
assert '&amp;' in html
assert '&quot;' in html