From 714f157551fbcc0dbc090343ede74647ab36f069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=AB=8B=E5=B8=AE?= <3294713004@qq.com> Date: Fri, 24 Oct 2025 22:18:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(boards):=20=E4=BF=AE=E5=A4=8Dmicropython?= =?UTF-8?q?=E4=B8=8B=E7=94=B1=E4=BA=8Eurllib=5Fparse=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E6=89=80=E5=AF=BC=E8=87=B4=E7=9A=84=E5=86=85=E5=AD=98=E5=8D=A0?= =?UTF-8?q?=E7=94=A8=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../origin/build/lib/tiny_webdb.py | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/boards/default_src/micropython/origin/build/lib/tiny_webdb.py b/boards/default_src/micropython/origin/build/lib/tiny_webdb.py index 2c513fe4..7ff1fde1 100644 --- a/boards/default_src/micropython/origin/build/lib/tiny_webdb.py +++ b/boards/default_src/micropython/origin/build/lib/tiny_webdb.py @@ -1,5 +1,16 @@ import urequests as requests -import urllib_parse + + +def url_quote(s): + safe = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-" + s = str(s) + res = bytearray() + for b in s.encode('utf-8'): + if b in safe: + res.append(b) + else: + res.extend(b'%' + b'%02X' % b) + return res.decode() class TinyWebDB: @@ -23,14 +34,14 @@ class TinyWebDB: self._password = password def update(self, key, value): - key = urllib_parse.quote(str(key)) - value = urllib_parse.quote(str(value)) + key = url_quote(str(key)) + value = url_quote(str(value)) result = self._request("update", "tag={}&value={}".format(key, value)) if "status" in result and result["status"] == "error": raise RuntimeError(result["message"]) def get(self, key): - key = urllib_parse.quote(str(key)) + key = url_quote(str(key)) result = self._request("get", "tag={}".format(key)) if "status" in result and result["status"] == "error": raise RuntimeError(result["message"]) @@ -45,14 +56,14 @@ class TinyWebDB: def search(self, no=1, count=1, tag='', dtype='both'): no = str(no) count = str(count) - tag = urllib_parse.quote(tag) + tag = url_quote(tag) result = self._request("search", "no={}&count={}&tag={}&type={}".format(no, count, tag, dtype)) if "status" in result and result["status"] == "error": raise RuntimeError(result["message"]) return result["data"] def delete(self, key): - key = urllib_parse.quote(str(key)) + key = url_quote(str(key)) result = self._request("delete", "tag={}".format(key)) if "status" in result and result["status"] == "error": raise RuntimeError(result["message"])