]> piware.de Git - bin.git/commitdiff
recipekeeper-split: Fix unescaped URLs
authorMartin Pitt <martin@piware.de>
Sat, 3 Jan 2026 16:43:31 +0000 (17:43 +0100)
committerMartin Pitt <martin@piware.de>
Sat, 3 Jan 2026 16:43:31 +0000 (17:43 +0100)
recipekeeper-split

index a56f52e68c312093c1c6287bc39f5d95675b0a53..c5104083091eca3dff5b3a3afff12349b7f32a17 100755 (executable)
@@ -33,6 +33,11 @@ content_fixed = re.sub(r'(<meta\b[^>]*)(?<!/)>', r'\1 />', content)
 # Only match when the value is not already quoted
 content_fixed = re.sub(r'itemprop=([^\s">]+)', r'itemprop="\1"', content_fixed)
 
+# 3. Fix unescaped ampersands in attribute values (& -> &amp;)
+# This handles ampersands in URLs and other attribute values
+# Only escape & that are not already part of an entity
+content_fixed = re.sub(r'&(?!amp;|lt;|gt;|quot;|apos;|#)', r'&amp;', content_fixed)
+
 # Parse as XML
 tree = ET.ElementTree(ET.fromstring(content_fixed))
 root = tree.getroot()