Skip to content

Commit 40be7f9

Browse files
committed
fix(feed): actually return proper atom including full content
Additionally, lets test for the appropriate content-type during tests.
1 parent e55c2c0 commit 40be7f9

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

test/test_advisory.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ def test_advisory_cve_listing_sorted_numerically(db, client):
345345
def test_advisory_atom_no_data(db, client):
346346
resp = client.get(url_for('tracker.advisory_atom'), follow_redirects=True)
347347
assert 200 == resp.status_code
348+
assert 'application/atom+xml; charset=utf-8' == resp.content_type
348349
data = resp.data.decode()
349350
assert DEFAULT_ADVISORY_ID not in data
350351

tracker/view/advisory.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
from re import match
33

44
from feedgen.feed import FeedGenerator
5+
from flask import Response
56
from flask import flash
6-
from flask import make_response
77
from flask import redirect
88
from flask import render_template
9-
from flask import request
109
from pytz import UTC
1110
from sqlalchemy import and_
1211

@@ -64,27 +63,31 @@ def advisory_atom():
6463
data = get_advisory_data()['published'][:TRACKER_FEED_ADVISORY_ENTRIES]
6564

6665
feed = FeedGenerator()
67-
feed.title('Arch Linux Security - Recent advisories')
68-
feed.description('Arch Linux recent advsisories RSS feed')
69-
feed.link(href=request.url_root)
66+
feed.id(TRACKER_ISSUE_URL.format('advisory'))
67+
feed.title('Arch Linux Security Advisories')
68+
feed.subtitle('Feed containing the last published Arch Linux Security Advisories')
69+
feed.link(href=TRACKER_ISSUE_URL.format('advisory'), rel='alternate')
70+
feed.link(href=TRACKER_ISSUE_URL.format('advisory/feed.atom'), rel='self')
71+
feed.language('en')
7072

7173
for entry in data:
7274
package = entry['package']
7375
advisory = entry['advisory']
74-
content=render_template('feed.html', content=advisory.content)
75-
summary=render_template('feed.html', content=advisory.impact)
76+
content = render_template('feed.html', content=advisory.content)
77+
impact = render_template('feed.html', content=advisory.impact)
7678
published = updated = advisory.created.replace(tzinfo=UTC)
7779

7880
entry = feed.add_entry()
81+
entry.id(TRACKER_ISSUE_URL.format(advisory.id))
7982
entry.title(f'[{advisory.id}] {package.pkgname}: {advisory.advisory_type}')
8083
entry.author(name='Arch Linux Security Team')
81-
entry.description(content)
82-
entry.description(summary, isSummary=True)
84+
entry.content(content.replace('\n', '<br/>'), type='html')
85+
entry.summary(impact.replace('\n', '<br/>'), type='html')
8386
entry.published(published)
8487
entry.updated(updated)
85-
entry.link(href=TRACKER_ISSUE_URL.format(advisory.id))
88+
entry.link(href=TRACKER_ISSUE_URL.format(advisory.id), rel='alternate')
8689

87-
return make_response(feed.rss_str())
90+
return Response(feed.atom_str(pretty=True), 200, content_type='application/atom+xml; charset=utf-8')
8891

8992

9093
@tracker.route('/advisory<regex("[./]json"):postfix>', methods=['GET'])

0 commit comments

Comments
 (0)