From 1b9ed27dd7049d048e861992a7846dd7d4688415 Mon Sep 17 00:00:00 2001 From: jsjiang Date: Thu, 3 Oct 2024 10:18:00 -0700 Subject: [PATCH 1/3] remove deprecated cgi pacakge --- impl/api.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/impl/api.py b/impl/api.py index 086180ea..9953f32c 100644 --- a/impl/api.py +++ b/impl/api.py @@ -83,7 +83,6 @@ """ import os import ast -import cgi import datetime import json import logging @@ -144,10 +143,21 @@ def _readInput(request): def is_text_plain_utf8(request): content_type = request.META.get('CONTENT_TYPE', '') - mimetype, options = cgi.parse_header(content_type) + mimetype = None + charset = None + if ';' in content_type: + [mimetype, charset] = content_type.split(';') + mimetype = mimetype.strip() + charset = charset.split('=')[1].strip() + else: + mimetype = content_type.strip() + + print(mimetype) + print(charset) + if mimetype not in ('text/plain', ''): return False - if options.get('charset', 'utf-8').lower() != 'utf-8': + if charset is not None and charset.lower() != 'utf-8': return False return True From 9e7123db7c9e32d3904253d48fd0c830bb020abe Mon Sep 17 00:00:00 2001 From: jsjiang Date: Thu, 3 Oct 2024 17:53:09 -0700 Subject: [PATCH 2/3] Fix Invalid escape warning using raw string literals prefixed with r --- impl/form_objects.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/impl/form_objects.py b/impl/form_objects.py index 27e16f82..bf39ba12 100644 --- a/impl/form_objects.py +++ b/impl/form_objects.py @@ -72,9 +72,9 @@ ('Workflow', _('Workflow')), ('Other', _('Other')), ) -REGEX_4DIGITYEAR = '^(\d{4}|\(:unac\)|\(:unal\)|\(:unap\)|\(:unas\)|\(:unav\)|\ +REGEX_4DIGITYEAR = r'^(\d{4}|\(:unac\)|\(:unal\)|\(:unap\)|\(:unas\)|\(:unav\)|\ \(:unkn\)|\(:none\)|\(:null\)|\(:tba\)|\(:etal\)|\(:at\))$' -REGEX_GEOPOINT = '-?(\d+(\.\d*)?|\.\d+)$' +REGEX_GEOPOINT = r'-?(\d+(\.\d*)?|\.\d+)$' # http://stackoverflow.com/questions/3962543/how-can-i-validate-a-culture-code-with-a-regular-expression REGEX_LANGUAGE = '^[a-z]{2,3}(?:-[A-Z]{2,3}(?:-[a-zA-Z]{4})?)?$' ERR_4DIGITYEAR = _("Four digits required") From 3a770b1507a3a84d5d8c5d0c48da6abc6bdeddb3 Mon Sep 17 00:00:00 2001 From: jsjiang Date: Thu, 3 Oct 2024 17:54:11 -0700 Subject: [PATCH 3/3] fix html coding error --- ui_tags/templatetags/manage_form_tags.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui_tags/templatetags/manage_form_tags.py b/ui_tags/templatetags/manage_form_tags.py index 62f6b3d1..c4317010 100644 --- a/ui_tags/templatetags/manage_form_tags.py +++ b/ui_tags/templatetags/manage_form_tags.py @@ -32,7 +32,7 @@ def column_choices(field_order, fields_mapped, fields_selected): def make_check_tag(item, friendly_names, selected): if item in selected: - checked_str = " checked='checked' " + checked_str = " checked='checked'" else: checked_str = "" return ( @@ -42,7 +42,7 @@ def make_check_tag(item, friendly_names, selected): + django.utils.html.escape(item) + "' value='t'" + checked_str - + " \> " + + " /> " + "