Skip to content

Commit

Permalink
SDAAP-123 Escaped Markup being included in headlines
Browse files Browse the repository at this point in the history
  • Loading branch information
marwoodandrew committed Sep 30, 2024
1 parent 416f873 commit 1cd9a67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from flask import current_app as app
from apps.prepopulate.app_initialize import get_filepath
from superdesk import etree as sd_etree
from superdesk.text_utils import get_text
from copy import deepcopy
from superdesk.utc import utcnow
from superdesk.editor_utils import remove_all_embeds
Expand Down Expand Up @@ -277,7 +278,8 @@ def _format_news_lines(self, formatted_article, main_news_component):
"""
news_lines = SubElement(main_news_component, "NewsLines")
if formatted_article.get('headline'):
SubElement(news_lines, 'HeadLine').text = formatted_article.get('headline')
SubElement(news_lines, 'HeadLine').text = (
get_text(formatted_article.get('headline'), 'html'))
if formatted_article.get('byline'):
SubElement(news_lines, 'ByLine').text = formatted_article.get('byline') or ''
if formatted_article.get('dateline', {}).get('text', ''):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ def test_embeded(self):
self.article['versioncreated'] = now
item = self.article.copy()
item.update({
'headline': 'headline is here',
'body_html':
'<p>pre amble</p>'
'<!-- EMBED START Image {id: \"editor_0\"} -->'
Expand All @@ -226,6 +227,8 @@ def test_embeded(self):
'format': 'HTML',
"fields_meta": {
"body_html": {
},
"headline": {
}
}
})
Expand All @@ -237,3 +240,5 @@ def test_embeded(self):
etree.tostring(newsml.find('./NewsItem/NewsComponent/NewsComponent/ContentItem/DataContent/'
'{http://www.w3.org/1999/xhtml}html/'
'{http://www.w3.org/1999/xhtml}body')).decode('utf-8'))
self.assertEqual('headline is here',
newsml.find('./NewsItem/NewsComponent/NewsComponent/NewsLines/HeadLine').text)

0 comments on commit 1cd9a67

Please sign in to comment.