Merge branch 'fix/v2.14.1-tags-captions' for v2.14.1 release
Build Container / build (push) Successful in 9m6s

This commit is contained in:
Phil committed 2026-11-10 15:37:43 -07:00
commit 88aea09e04
12 files changed
+163 -23

No files matched your search

+7
View File
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [2.14.1] - 2026-11-10
### Fixed
- Clearing the Tags field in the note editor removes all of the note's tags. It used to leave them unchanged, so a note's last tags couldn't be removed from the editor
- Image captions are escaped in the HTML of RSS, Atom and JSON Feed items. A caption containing `"`, `<` or `&` broke the item's image markup (the Atom enclosure's title was already escaped)
## [2.14.0] - 2026-11-10 ## [2.14.0] - 2026-11-10
Notifications (ADR-074). Notifications (ADR-074).
+5 -1
View File
@@ -21,7 +21,7 @@ is in `../architecture/`; decisions are in `../decisions/` (ADRs).
## Contents ## Contents
[v0.x](#v0x) · [v1.0.0](#v100) · [v1.1.1](#v111) · [v1.1.2](#v112) · [v1.2.0](#v120) · [v1.3.0](#v130) · [v1.3.1](#v131) · [v1.4.0](#v140) · [v1.4.1](#v141) · [v1.4.2](#v142) · [v1.5.0](#v150) · [v1.6.0](#v160) · [v2.0.0](#v200) · [v2.0.1](#v201) · [v2.0.2](#v202) · [v2.1.0](#v210) · [v2.2.0](#v220) · [v2.3.0](#v230) · [v2.3.1](#v231) · [v2.3.2](#v232) · [v2.3.3](#v233) · [v2.4.0](#v240) · [v2.5.0](#v250) · [v2.6.0](#v260) · [v2.6.1](#v261) · [v2.6.2](#v262) · [v2.6.3](#v263) · [v2.6.4](#v264) · [v2.6.5](#v265) · [v2.6.6](#v266) · [v2.6.7](#v267) · [v2.6.8](#v268) · [v2.6.9](#v269) · [v2.7.0](#v270) · [v2.7.1](#v271) · [v2.7.2](#v272) · [v2.8.0](#v280) · [v2.8.1](#v281) · [v2.9.0](#v290) · [v2.10.0](#v2100) · [v2.10.1](#v2101) · [v2.10.2](#v2102) · [v2.11.0](#v2110) · [v2.12.0](#v2120) · [v2.12.1](#v2121) · [v2.13.0](#v2130) · [v2.13.1](#v2131) · [v2.13.2](#v2132) · [v2.13.3](#v2133) · [v2.13.4](#v2134) · [v2.14.0](#v2140) · [hotfix](#hotfix) [v0.x](#v0x) · [v1.0.0](#v100) · [v1.1.1](#v111) · [v1.1.2](#v112) · [v1.2.0](#v120) · [v1.3.0](#v130) · [v1.3.1](#v131) · [v1.4.0](#v140) · [v1.4.1](#v141) · [v1.4.2](#v142) · [v1.5.0](#v150) · [v1.6.0](#v160) · [v2.0.0](#v200) · [v2.0.1](#v201) · [v2.0.2](#v202) · [v2.1.0](#v210) · [v2.2.0](#v220) · [v2.3.0](#v230) · [v2.3.1](#v231) · [v2.3.2](#v232) · [v2.3.3](#v233) · [v2.4.0](#v240) · [v2.5.0](#v250) · [v2.6.0](#v260) · [v2.6.1](#v261) · [v2.6.2](#v262) · [v2.6.3](#v263) · [v2.6.4](#v264) · [v2.6.5](#v265) · [v2.6.6](#v266) · [v2.6.7](#v267) · [v2.6.8](#v268) · [v2.6.9](#v269) · [v2.7.0](#v270) · [v2.7.1](#v271) · [v2.7.2](#v272) · [v2.8.0](#v280) · [v2.8.1](#v281) · [v2.9.0](#v290) · [v2.10.0](#v2100) · [v2.10.1](#v2101) · [v2.10.2](#v2102) · [v2.11.0](#v2110) · [v2.12.0](#v2120) · [v2.12.1](#v2121) · [v2.13.0](#v2130) · [v2.13.1](#v2131) · [v2.13.2](#v2132) · [v2.13.3](#v2133) · [v2.13.4](#v2134) · [v2.14.0](#v2140) · [v2.14.1](#v2141) · [hotfix](#hotfix)
## v0.x ## v0.x
@@ -452,6 +452,10 @@ OIDC admin login and built-in IndieAuth server.
- [2026-11-10-notifications.md](v2.14.0/2026-11-10-notifications.md) — Notifications (implementation report) - [2026-11-10-notifications.md](v2.14.0/2026-11-10-notifications.md) — Notifications (implementation report)
## v2.14.1
- [2026-11-10-tags-and-captions.md](v2.14.1/2026-11-10-tags-and-captions.md) — Clearing tags in the editor; captions escaped in feeds
## hotfix ## hotfix
Not a release folder. Not a release folder.
@@ -0,0 +1,27 @@
# v2.14.1: Clearing tags in the editor; captions escaped in feeds
Two bugs from the backlog (High), confirmed against the code at v2.14.0.
## Clearing tags
`routes/admin.py` (edit POST) passed `tags=tags if tags else None`, and
`notes.update_note` treats `None` as "unchanged", so an empty Tags field
kept the old tags although the form says "Leave blank to remove all tags".
It now passes the parsed list (possibly empty) whenever the form has a
`tags` field, and `None` only when it doesn't.
## Captions in feed HTML
The media `<img>` built for item HTML put the caption into `alt="…"`
unescaped in four places: `feeds/rss.py` (two), `feeds/atom.py` and
`feeds/json_feed.py`. A caption with `"`, `<` or `&` broke the markup. The
caption and the media URL are now `html.escape(..., quote=True)`d. The
Atom enclosure's `title` attribute was already escaped with `_escape_xml`
and is unchanged (escaping it again would double it).
## Verification
`tests/test_tags_and_captions.py` (4 tests, all failing before the fix):
caption escaped once in RSS, Atom (and the enclosure title not doubled) and
JSON Feed; the editor leaves tags alone without the field and clears them
with an empty one. Feed, admin, tag, public-route and media tests pass.
+3 -11
View File
@@ -23,17 +23,7 @@ at v2.14.0. Work that has shipped is listed per release in `vX.Y.Z/RELEASE.md` a
## High ## High
Bugs (DOCUMENTATION.md: bugs are High). None open.
### Admin editor cannot clear all tags
- **Description**: When a note is saved with an empty tag field, the route passes `tags=None`. `update_note` treats that as "unchanged", so the last tags can't be removed from the editor.
- **Where**: `starpunk/routes/admin.py` (edit POST: `tags=tags if tags else None`), `starpunk/notes.py` (`update_note`)
- **Source**: Old backlog (v1.3.0 follow-up); still present
### Media captions not escaped in RSS HTML
- **Description**: The RSS description embeds `<img alt="{caption}">` without escaping the caption. A caption containing `"` or `<` breaks the item's HTML.
- **Where**: `starpunk/feeds/rss.py` (two places, lines 131 and 258)
- **Source**: Old backlog (Architect Review 2.2.10); still present
--- ---
@@ -185,6 +175,8 @@ Bugs (DOCUMENTATION.md: bugs are High).
These items were removed from the backlog because they have shipped: These items were removed from the backlog because they have shipped:
- v2.14.1: the editor can clear all tags; image captions escaped in RSS, Atom and JSON Feed HTML
- v2.14.0: notifications of new responses and crosspost/backfeed problems through Apprise (ADR-074) - v2.14.0: notifications of new responses and crosspost/backfeed problems through Apprise (ADR-074)
- v2.13.0–v2.13.4: backfeed of likes, reposts, quotes and replies from GoToSocial, Bluesky and Threads (ADR-073); counts line with web actions; counts on lists of notes; local avatar copies - v2.13.0–v2.13.4: backfeed of likes, reposts, quotes and replies from GoToSocial, Bluesky and Threads (ADR-073); counts line with web actions; counts on lists of notes; local avatar copies
- v2.12.1: Micropub `q=category` lists only tags in use - v2.12.1: Micropub `q=category` lists only tags in use
+1
View File
@@ -56,3 +56,4 @@ Future work and per-release plans. See `../DOCUMENTATION.md` (PROJECTPLAN).
- **[v2.13.3](v2.13.3/RELEASE.md)** - Opted-out people counted without names (Released 2026-11-10) - **[v2.13.3](v2.13.3/RELEASE.md)** - Opted-out people counted without names (Released 2026-11-10)
- **[v2.13.4](v2.13.4/RELEASE.md)** - Counts on lists of notes, reply cards link out (Released 2026-11-10) - **[v2.13.4](v2.13.4/RELEASE.md)** - Counts on lists of notes, reply cards link out (Released 2026-11-10)
- **[v2.14.0](v2.14.0/RELEASE.md)** - Notifications through Apprise (Released 2026-11-10) - **[v2.14.0](v2.14.0/RELEASE.md)** - Notifications through Apprise (Released 2026-11-10)
- **[v2.14.1](v2.14.1/RELEASE.md)** - Clearing tags in the editor; captions escaped in feeds (Released 2026-11-10)
+15
View File
@@ -0,0 +1,15 @@
# v2.14.1
- **Date**: 2026-11-10
- **Status**: Released
- **Focus**: The two High backlog bugs
## Fixed
- The editor can clear all of a note's tags
- Image captions escaped in RSS, Atom and JSON Feed item HTML
## Related
- [CHANGELOG](../../../CHANGELOG.md)
- [Design note](../../design/v2.14.1/2026-11-10-tags-and-captions.md)
+2 -2
View File
@@ -465,5 +465,5 @@ def create_app(config=None):
# Package version (Semantic Versioning 2.0.0) # Package version (Semantic Versioning 2.0.0)
# See docs/standards/versioning-strategy.md for details # See docs/standards/versioning-strategy.md for details
__version__ = "2.14.0" __version__ = "2.14.1"
__version_info__ = (2, 14, 0) __version_info__ = (2, 14, 1)
+3 -2
View File
@@ -16,6 +16,7 @@ Standards:
""" """
# Standard library imports # Standard library imports
from html import escape
from datetime import datetime, timezone from datetime import datetime, timezone
from typing import Optional from typing import Optional
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
@@ -199,8 +200,8 @@ def generate_atom_streaming(
html_content += '<div class="media">' html_content += '<div class="media">'
for item in note.media: for item in note.media:
media_url = f"{site_url}/media/{item['path']}" media_url = f"{site_url}/media/{item['path']}"
caption = item.get('caption', '') caption = escape(item.get('caption') or '', quote=True) # v2.14.1
html_content += f'<img src="{media_url}" alt="{caption}" />' html_content += f'<img src="{escape(media_url, quote=True)}" alt="{caption}" />'
html_content += '</div>' html_content += '</div>'
# Add text content below media # Add text content below media
+3 -2
View File
@@ -16,6 +16,7 @@ Standards:
""" """
# Standard library imports # Standard library imports
from html import escape
from datetime import datetime, timezone from datetime import datetime, timezone
from typing import Optional, Dict, Any from typing import Optional, Dict, Any
import json import json
@@ -247,8 +248,8 @@ def _build_item_object(site_url: str, note: Note) -> Dict[str, Any]:
content_html += '<div class="media">' content_html += '<div class="media">'
for media_item in note.media: for media_item in note.media:
media_url = f"{site_url}/media/{media_item['path']}" media_url = f"{site_url}/media/{media_item['path']}"
caption = media_item.get('caption', '') caption = escape(media_item.get('caption') or '', quote=True) # v2.14.1
content_html += f'<img src="{media_url}" alt="{caption}" />' content_html += f'<img src="{escape(media_url, quote=True)}" alt="{caption}" />'
content_html += '</div>' content_html += '</div>'
# Add text content below media # Add text content below media
+5 -4
View File
@@ -20,6 +20,7 @@ Standards:
""" """
# Standard library imports # Standard library imports
from html import escape
from datetime import datetime, timezone from datetime import datetime, timezone
from typing import Optional from typing import Optional
@@ -127,8 +128,8 @@ def generate_rss(
html_content += '<div class="media">' html_content += '<div class="media">'
for item in note.media: for item in note.media:
media_url = f"{site_url}/media/{item['path']}" media_url = f"{site_url}/media/{item['path']}"
caption = item.get('caption', '') caption = escape(item.get('caption') or '', quote=True) # v2.14.1
html_content += f'<img src="{media_url}" alt="{caption}" />' html_content += f'<img src="{escape(media_url, quote=True)}" alt="{caption}" />'
html_content += '</div>' html_content += '</div>'
# Add text content below media # Add text content below media
@@ -254,8 +255,8 @@ def generate_rss_streaming(
html_content += '<div class="media">' html_content += '<div class="media">'
for item in note.media: for item in note.media:
media_url = f"{site_url}/media/{item['path']}" media_url = f"{site_url}/media/{item['path']}"
caption = item.get('caption', '') caption = escape(item.get('caption') or '', quote=True) # v2.14.1
html_content += f'<img src="{media_url}" alt="{caption}" />' html_content += f'<img src="{escape(media_url, quote=True)}" alt="{caption}" />'
html_content += '</div>' html_content += '</div>'
# Add text content below media # Add text content below media
+3 -1
View File
@@ -309,7 +309,9 @@ def update_note_submit(note_id: int):
id=note_id, id=note_id,
content=content, content=content,
published=published, published=published,
tags=tags if tags else None # An empty Tags field removes all tags (v2.14.1); a form without
# the field leaves them alone
tags=tags if "tags" in request.form else None
) )
if "syndication_form" in request.form: if "syndication_form" in request.form:
from starpunk.syndication import select_targets from starpunk.syndication import select_targets
+89
View File
@@ -0,0 +1,89 @@
"""
v2.14.1 fixes: clearing all tags in the editor, and media captions escaped
in the HTML of RSS, Atom and JSON Feed items.
"""
import io
import json
from xml.etree import ElementTree as ET
import pytest
from PIL import Image
from starpunk import create_app
from starpunk.media import attach_media_to_note, save_media
from starpunk.notes import create_note
from starpunk.tags import get_note_tags
CAPTION = 'Say "hi" <b>bold</b> & more'
ESCAPED = 'alt="Say &quot;hi&quot; &lt;b&gt;bold&lt;/b&gt; &amp; more"'
@pytest.fixture
def app(tmp_path):
data = tmp_path / "data"
app = create_app({
"TESTING": True, "DATABASE_PATH": data / "starpunk.db", "DATA_PATH": data,
"NOTES_PATH": data / "notes", "SESSION_SECRET": "x", "ADMIN_ME": "https://example.com",
"SITE_URL": "https://blog.example.com", "SITE_NAME": "Test", "CSRF_ENABLED": False,
})
yield app
def png():
buf = io.BytesIO()
Image.new("RGB", (800, 600), "red").save(buf, "PNG")
return buf.getvalue()
@pytest.fixture
def captioned(app):
with app.app_context():
note = create_note(content="A photo", published=True)
media = save_media(png(), "photo.png")
attach_media_to_note(note.id, [media["id"]], [CAPTION])
return note
def test_rss_caption_escaped(app, captioned):
body = app.test_client().get("/feed.rss").get_data(as_text=True)
description = ET.fromstring(body).find("./channel/item/description").text
assert ESCAPED in description
assert "<b>bold</b>" not in description
def test_atom_caption_escaped_once(app, captioned):
body = app.test_client().get("/feed.atom").get_data(as_text=True)
ns = {"a": "http://www.w3.org/2005/Atom"}
entry = ET.fromstring(body).find("a:entry", ns)
content = entry.find("a:content", ns).text
assert ESCAPED in content and "<b>bold</b>" not in content
# The enclosure's title attribute was already escaped; not twice
enclosure = next(l for l in entry.findall("a:link", ns) if l.get("rel") == "enclosure")
assert enclosure.get("title") == CAPTION
def test_json_feed_caption_escaped(app, captioned):
item = json.loads(app.test_client().get("/feed.json").get_data(as_text=True))["items"][0]
assert ESCAPED in item["content_html"] and "<b>bold</b>" not in item["content_html"]
def test_editor_can_clear_all_tags(app):
from starpunk.auth import create_session
with app.app_context():
note = create_note(content="Tagged", published=True, tags=["one", "two"])
with app.test_request_context():
token = create_session("https://example.com")
client = app.test_client()
client.set_cookie("starpunk_session", token)
# A form without the Tags field leaves the tags alone
client.post(f"/admin/edit/{note.id}", data={"content": "Tagged", "published": "on"})
with app.app_context():
assert {t["name"] for t in get_note_tags(note.id)} == {"one", "two"}
# An empty Tags field removes them all
client.post(f"/admin/edit/{note.id}", data={"content": "Tagged", "published": "on", "tags": ""})
with app.app_context():
assert get_note_tags(note.id) == []