Skip to content

Commit

Permalink
blog user page UI: strip HTML from original post links
Browse files Browse the repository at this point in the history
  • Loading branch information
snarfed committed Nov 29, 2023
1 parent a31bdc8 commit 726acda
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from flask import render_template, request
from google.cloud import ndb
from granary import as1
from granary.source import html_to_text
from oauth_dropins.webutil import logs
from oauth_dropins.webutil import flask_util
from oauth_dropins.webutil.flask_util import error, flash
Expand Down Expand Up @@ -265,7 +266,7 @@ def get_paging_param(param):
for b in blogposts:
b.links = process_webmention_links(b)
try:
text = b.feed_item.get('title')
text = html_to_text(b.feed_item.get('title'))
except ValueError:
text = None
b.pretty_url = util.pretty_link(
Expand Down
5 changes: 2 additions & 3 deletions tests/test_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,8 @@ def test_user_page_responses_before_after(self):
resp = self.client.get(f'{self.sources[0].bridgy_path()}?{param}=2022-05-09T10:13:28.597816 00:00')
self.assertEqual(200, resp.status_code)

def test_blog_user_page_escapes_html_chars(self):
def test_blog_user_page_strips_html(self):
html = '<xyz> a&b'
escaped = '&lt;xyz&gt; a&amp;b'

source = FakeBlogSource.new()
source.features = ['webmention']
Expand All @@ -503,7 +502,7 @@ def test_blog_user_page_escapes_html_chars(self):
resp = self.client.get(source.bridgy_path())
self.assertEqual(200, resp.status_code)
self.assertNotIn(html, resp.get_data(as_text=True))
self.assertIn(escaped, resp.get_data(as_text=True))
self.assertIn('ab', resp.get_data(as_text=True))

def test_users_page(self):
self.sources[1].put()
Expand Down

0 comments on commit 726acda

Please sign in to comment.