mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-29 17:36:49 +01:00
Ensure HTML entities are unescaped in html-to-contentstate conversion
This commit is contained in:
parent
9fadf1cb21
commit
581e9a92c0
@ -273,7 +273,7 @@ class HtmlToContentStateHandler(HTMLParser):
|
||||
if rule is not None:
|
||||
self.element_handlers.add_rules(rule['from_database_format'])
|
||||
|
||||
super().__init__()
|
||||
super().__init__(convert_charrefs=True)
|
||||
|
||||
def reset(self):
|
||||
self.state = HandlerState()
|
||||
|
@ -659,3 +659,17 @@ class TestHtmlToContentState(TestCase):
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
def test_html_entities(self):
|
||||
converter = ContentstateConverter(features=[])
|
||||
result = json.loads(converter.from_database_format(
|
||||
'''
|
||||
<p>Arthur "two sheds" Jackson <the third> & his wife</p>
|
||||
'''
|
||||
))
|
||||
self.assertContentStateEqual(result, {
|
||||
'entityMap': {},
|
||||
'blocks': [
|
||||
{'inlineStyleRanges': [], 'text': 'Arthur "two sheds" Jackson <the third> & his wife', 'depth': 0, 'type': 'unstyled', 'key': '00000', 'entityRanges': []},
|
||||
]
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user