From 3424f494ef1b2e6643d09702151088244c48def5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= jaakko.keranen@iki.fi
Date: Wed, 18 Oct 2023 12:01:59 +0300
Subject: [PATCH 1/1] Strip null characters from segment text
When updating and rendering segments, strip any null characters.
50_bubble.py | 2 +-
model.py | 5 +++--
utils.py | 4 ++++
3 files changed, 8 insertions(+), 3 deletions(-)
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, \
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):
def shorten_text(text, n):
"""Truncate and cut at white or word boundary."""
if len(text) > n:
--
2.25.1
text/plain
This content has been proxied by September (ba2dc).