From d9a727f5f359efad790b9a631d8c6e3cb63c3016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Junnos=20=EF=A3=BF?= Date: Mon, 30 Jun 2025 10:29:51 +0900 Subject: [PATCH] fix: Replace emojis from commit messages while generating version --- label_studio/core/templatetags/filters.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/label_studio/core/templatetags/filters.py b/label_studio/core/templatetags/filters.py index efd44bc58a84..6d136c72e985 100644 --- a/label_studio/core/templatetags/filters.py +++ b/label_studio/core/templatetags/filters.py @@ -52,7 +52,20 @@ def get_item(dictionary, key): @register.filter def json_dumps_ensure_ascii(dictionary): - return json.dumps(dictionary, ensure_ascii=False) + def clean_surrogates(obj): + """Recursively clean surrogate characters from strings in nested data structures""" + if isinstance(obj, str): + # Replace surrogate characters with replacement character + return obj.encode('utf-8', errors='replace').decode('utf-8') + elif isinstance(obj, dict): + return {k: clean_surrogates(v) for k, v in obj.items()} + elif isinstance(obj, list): + return [clean_surrogates(item) for item in obj] + else: + return obj + + cleaned_dictionary = clean_surrogates(dictionary) + return json.dumps(cleaned_dictionary, ensure_ascii=False) @register.filter