From 11c789c71c32b2247e5cbc421d615ce5334547c7 Mon Sep 17 00:00:00 2001 From: whyour Date: Sun, 25 Feb 2024 15:27:48 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20webhook=20=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=20body=20=E6=8B=86=E5=88=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/config/util.ts | 48 +++++++++++++++++++++----------------- sample/notify.js | 48 +++++++++++++++++++++----------------- sample/notify.py | 38 ++++++++++++++---------------- src/pages/log/index.tsx | 6 ++--- src/pages/script/index.tsx | 6 ++--- 5 files changed, 76 insertions(+), 70 deletions(-) diff --git a/back/config/util.ts b/back/config/util.ts index 0872547a..4f53280a 100644 --- a/back/config/util.ts +++ b/back/config/util.ts @@ -360,6 +360,31 @@ export function parseHeaders(headers: string) { return parsed; } +function parseString(input: string): Record { + const regex = /(\w+):\s*((?:(?!\n\w+:).)*)/g; + const matches: Record = {}; + + let match; + while ((match = regex.exec(input)) !== null) { + const [, key, value] = match; + const _key = key.trim(); + if (!_key || matches[_key]) { + continue; + } + + const _value = value.trim(); + + try { + const jsonValue = JSON.parse(_value); + matches[_key] = jsonValue; + } catch (error) { + matches[_key] = _value; + } + } + + return matches; +} + export function parseBody( body: string, contentType: @@ -372,28 +397,7 @@ export function parseBody( return body; } - const parsed: any = {}; - let key; - let val; - let i; - - body && - body.split('\n').forEach(function parser(line) { - i = line.indexOf(':'); - key = line.substring(0, i).trim(); - val = line.substring(i + 1).trim(); - - if (!key || parsed[key]) { - return; - } - - try { - const jsonValue = JSON.parse(val); - parsed[key] = jsonValue; - } catch (error) { - parsed[key] = val; - } - }); + const parsed = parseString(body); switch (contentType) { case 'multipart/form-data': diff --git a/sample/notify.js b/sample/notify.js index 74776b0f..1e5eee95 100644 --- a/sample/notify.js +++ b/sample/notify.js @@ -1315,6 +1315,31 @@ function webhookNotify(text, desp) { }); } +function parseString(input) { + const regex = /(\w+):\s*((?:(?!\n\w+:).)*)/g; + const matches = {}; + + let match; + while ((match = regex.exec(input)) !== null) { + const [, key, value] = match; + const _key = key.trim(); + if (!_key || matches[_key]) { + continue; + } + + const _value = value.trim(); + + try { + const jsonValue = JSON.parse(_value); + matches[_key] = jsonValue; + } catch (error) { + matches[_key] = _value; + } + } + + return matches; +} + function parseHeaders(headers) { if (!headers) return {}; @@ -1344,28 +1369,7 @@ function parseBody(body, contentType) { return body; } - const parsed = {}; - let key; - let val; - let i; - - body && - body.split('\n').forEach(function parser(line) { - i = line.indexOf(':'); - key = line.substring(0, i).trim(); - val = line.substring(i + 1).trim(); - - if (!key || parsed[key]) { - return; - } - - try { - const jsonValue = JSON.parse(val); - parsed[key] = jsonValue; - } catch (error) { - parsed[key] = val; - } - }); + const parsed = parseString(body); switch (contentType) { case 'multipart/form-data': diff --git a/sample/notify.py b/sample/notify.py index 66fc5c1e..1cb4a944 100644 --- a/sample/notify.py +++ b/sample/notify.py @@ -578,7 +578,9 @@ def aibotk(title: str, content: str) -> None: or not push_config.get("AIBOTK_TYPE") or not push_config.get("AIBOTK_NAME") ): - print("智能微秘书 的 AIBOTK_KEY 或者 AIBOTK_TYPE 或者 AIBOTK_NAME 未设置!!\n取消推送") + print( + "智能微秘书 的 AIBOTK_KEY 或者 AIBOTK_TYPE 或者 AIBOTK_NAME 未设置!!\n取消推送" + ) return print("智能微秘书 服务启动") @@ -748,29 +750,25 @@ def parse_headers(headers): return parsed +def parse_string(input_string): + matches = {} + pattern = r'(\w+):\s*((?:(?!\n\w+:).)*)' + regex = re.compile(pattern) + for match in regex.finditer(input_string): + key, value = match.group(1).strip(), match.group(2).strip() + try: + json_value = json.loads(value) + matches[key] = json_value + except: + matches[key] = value + return matches + + def parse_body(body, content_type): if not body or content_type == "text/plain": return body - parsed = {} - lines = body.split("\n") - - for line in lines: - i = line.find(":") - if i == -1: - continue - - key = line[:i].strip() - val = line[i + 1 :].strip() - - if not key or key in parsed: - continue - - try: - json_value = json.loads(val) - parsed[key] = json_value - except: - parsed[key] = val + parsed = parse_string(input_string) if content_type == "application/x-www-form-urlencoded": data = urlencode(parsed, doseq=True) diff --git a/src/pages/log/index.tsx b/src/pages/log/index.tsx index f2fc232a..818a74e1 100644 --- a/src/pages/log/index.tsx +++ b/src/pages/log/index.tsx @@ -68,13 +68,13 @@ const Log = () => { }; const onSelect = (value: any, node: any) => { - setCurrentNode(node); - setSelect(value); - if (node.key === select || !value) { return; } + setCurrentNode(node); + setSelect(value); + if (node.type === 'directory') { setValue(intl.get('请选择日志文件')); return; diff --git a/src/pages/script/index.tsx b/src/pages/script/index.tsx index b46954e9..10251b1b 100644 --- a/src/pages/script/index.tsx +++ b/src/pages/script/index.tsx @@ -115,13 +115,13 @@ const Script = () => { }; const onSelect = (value: any, node: any) => { - setSelect(node.key); - setCurrentNode(node); - if (node.key === select || !value) { return; } + setSelect(node.key); + setCurrentNode(node); + if (node.type === 'directory') { setValue(intl.get('请选择脚本文件')); return; From f07093d29f22189bf48350326b79c030bcbcd4f8 Mon Sep 17 00:00:00 2001 From: pharaoh2012 <2225220+pharaoh2012@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:15:58 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BC=81=E4=B8=9A=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=9C=89=E9=95=BF=E5=BA=A6=E9=99=90=E5=88=B6=EF=BC=8C=E8=B6=85?= =?UTF-8?q?=E9=95=BF=E7=9A=84=E8=BF=9B=E8=A1=8C=E5=88=86=E6=AE=B5=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=20(#2255)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sample/notify.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sample/notify.js b/sample/notify.js index 1e5eee95..55f84bc4 100644 --- a/sample/notify.js +++ b/sample/notify.js @@ -816,7 +816,18 @@ function ChangeUserId(desp) { } } -function qywxamNotify(text, desp) { +async function qywxamNotify(text, desp) { + const MAX_LENGTH = 900; + if (desp.length > MAX_LENGTH) { + let d = desp.substr(0, MAX_LENGTH) + "\n==More=="; + await do_qywxamNotify(text, d); + await qywxamNotify(text, desp.substr(MAX_LENGTH)); + } else { + return await do_qywxamNotify(text,desp); + } +} + +function do_qywxamNotify(text, desp) { return new Promise((resolve) => { if (QYWX_AM) { const QYWX_AM_AY = QYWX_AM.split(','); From b39036f8f8d931c3f543422f82f371bfa4766723 Mon Sep 17 00:00:00 2001 From: whyour Date: Sat, 2 Mar 2024 16:22:18 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=8F=96=E6=B6=88=E7=94=9F=E6=88=90=20core?= =?UTF-8?q?=20=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/310.Dockerfile | 3 ++- docker/Dockerfile | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docker/310.Dockerfile b/docker/310.Dockerfile index c034a15d..e129e541 100644 --- a/docker/310.Dockerfile +++ b/docker/310.Dockerfile @@ -53,7 +53,8 @@ RUN set -x \ && rm -rf /root/.pnpm-store \ && rm -rf /root/.local/share/pnpm/store \ && rm -rf /root/.cache \ - && rm -rf /root/.npm + && rm -rf /root/.npm \ + && ulimit -c 0 ARG SOURCE_COMMIT RUN git clone --depth=1 -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} \ diff --git a/docker/Dockerfile b/docker/Dockerfile index cb946602..cfda87b0 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -57,7 +57,8 @@ RUN set -x \ && rm -rf /root/.pnpm-store \ && rm -rf /root/.local/share/pnpm/store \ && rm -rf /root/.cache \ - && rm -rf /root/.npm + && rm -rf /root/.npm \ + && ulimit -c 0 ARG SOURCE_COMMIT RUN git clone --depth=1 -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} \ From 55945e4cd188ba7ea7d063e1b0a143042aec4877 Mon Sep 17 00:00:00 2001 From: whyour Date: Sat, 2 Mar 2024 16:24:30 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC=20v2.1?= =?UTF-8?q?7.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- version.yaml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/version.yaml b/version.yaml index c46113cc..3f107b45 100644 --- a/version.yaml +++ b/version.yaml @@ -1,13 +1,7 @@ -version: 2.17.1 -changeLogLink: https://t.me/jiao_long/402 -publishTime: 2024-02-07 23:00 +version: 2.17.2 +changeLogLink: https://t.me/jiao_long/403 +publishTime: 2024-03-02 17:00 changeLog: | - 1. 系统设置增加重启 - 2. 修复 debian 系统内更新源代码分支错误 - 3. 修复启动时依赖配置未初始化 - 4. 修复未开启一言时多余空行, 通知渠道改发送前检查,感谢 https://github.com/Cp0204 - 5. Dockerfile 添加发布端口和数据卷 https://github.com/Akimio521 - 6. 修复有反向代理时脚本管理获取文件可能失败 - 7. 脚本管理重命名增加默认值,增加新建(mod+o)、删除快捷键(mod+d) - 8. 修复对比工具保存文件 - 9. 其他 bug 修复 + 1. 依赖管理支持队列中依赖取消安装,支持状态筛选 + 2. 修复 webhook 通知 body 拆分逻辑 + 3. 企业微信有长度限制,超长的进行分段提交 https://github.com/pharaoh2012