Bubble [main]

Strip null characters from segment text

=> 3424f494ef1b2e6643d09702151088244c48def5

diff --git a/50_bubble.py b/50_bubble.py
index 6b41984..dc31000 100644
--- a/50_bubble.py
+++ b/50_bubble.py
@@ -353,7 +353,7 @@ Bubble is open source:
                         src += '\n'
 
                 if segment.type == Segment.TEXT:
-                    src += prefix_links(segment.content, link_prefix) + '\n'
+                    src += prefix_links(strip_invalid(segment.content), link_prefix) + '\n'
                     last_type = segment.type
 
                 elif segment.type in [Segment.LINK, Segment.IMAGE, Segment.ATTACHMENT]:
diff --git a/model.py b/model.py
index b9c28bd..2a99366 100644
--- a/model.py
+++ b/model.py
@@ -9,7 +9,8 @@ from gmcapsule import Identity
 from OpenSSL import crypto
 from typing import Union
 from utils import ago_text, clean_title, parse_at_names, shorten_text, strip_links, \
-    GeminiError, UTC, INNER_LINK_PREFIX, gemini_fetch, certificate_sha256, pubkey_sha256
+    GeminiError, UTC, INNER_LINK_PREFIX, gemini_fetch, certificate_sha256, pubkey_sha256, \
+    strip_invalid
 
 
 def parse_asn1_time(asn1_bytes):
@@ -1361,7 +1362,7 @@ class Database:
         values = []
         if content != None:
             set_stm.append('content=?')
-            values.append(content)
+            values.append(strip_invalid(content))
             old_content = segment.content
             segment.content = content
         if url != None:
diff --git a/utils.py b/utils.py
index 99dfa87..46fdff8 100644
--- a/utils.py
+++ b/utils.py
@@ -163,6 +163,10 @@ def prefix_links(src, prefix):
     return '\n'.join(lines)
 
 
+def strip_invalid(src):
+    return src.replace('\x00', '')
+
+
 def shorten_text(text, n):
     """Truncate and cut at white or word boundary."""
     if len(text) > n:
Proxy Information
Original URL
gemini://git.skyjake.fi/bubble/main/cdiff/3424f494ef1b2e6643d09702151088244c48def5
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
28.649055 milliseconds
Gemini-to-HTML Time
0.273967 milliseconds

This content has been proxied by September (ba2dc).