pppscn / SmsForwarder

短信转发器——监控Android手机短信、来电、APP通知,并根据指定规则转发到其他手机:钉钉群自定义机器人、钉钉企业内机器人、企业微信群机器人、飞书机器人、企业微信应用消息、邮箱、bark、webhook、Telegram机器人、Server酱、PushPlus、手机短信等。包括主动控制服务端与客户端,让你轻松远程发短信、查短信、查通话、查话簿、查电量等。(V3.0 新增)PS.这个APK主要是学习与自用,如有BUG请提ISSUE,同时欢迎大家提PR指正

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: 使用Webhook POST提交内容带style样式后续内容会被扔掉

fcwys opened this issue · comments

是否有人曾提过类似的问题

否(No)

升级到最新的版本是否存在这个问题

否(No)

是否已经查阅Wiki文档还未能解决的

否(No)

APP版本

v3.3.1.240418

问题描述

使用 爱语飞飞 POST提交内容带style样式后续内容会被扔掉,例如 text=告警通知&desp=<pre style="white-space:break-spaces">[msg]</pre> 则&desp后面内容丢失,使用Postman使用相同参数请求正常。

复现步骤

模板使用 text=告警通知&desp=<pre style="white-space:break-spaces">[msg]</pre>

是否必现

是(Yes)

出现问题的手机信息

Redmi K40S

出现问题的安卓版本、系统版本

Android14

提供截图或视频

e65aa4e134e316464427a1a2c15c57a
image

提供报错堆栈【请提供logcat抓取的日志,参考: https://blog.csdn.net/m0_64776928/article/details/126005119

2024-05-23 12:14:50.637 | E | SendersFragment | Sender(id=1, type=3, name=爱语飞飞, jsonSetting={"headers":{},"method":"POST","proxyAuthenticator":false,"proxyHost":"","proxyPassword":"","proxyPort":"","proxyType":"DIRECT","proxyUsername":"","response":"","secret":"","webParams":"text\u003d告警通知\u0026desp\u003d\u003cpre style\u003d\"white-space:break-spaces;\"\u003e[msg]\u003c/pre\u003e","webServer":"https://iyuu.cn/IYUU15785T83034161cb23ec10d4291934c0**************.send"}, status=1, time=Thu May 23 12:14:43 GMT+08:00 2024)

2024-05-23 12:14:50.710 | D | WebhookFragment | WebhookSetting(method=POST, webServer=https://iyuu.cn/IYUU15785T83034161cb23ec10d4291934c0**************.send, secret=, response=, webParams=text=告警通知&desp=<pre style="white-space:break-spaces;">[msg]</pre>, headers={}, proxyType=DIRECT, proxyHost=, proxyPort=, proxyAuthenticator=false, proxyUsername=, proxyPassword=)

2024-05-23 12:14:56.668 | D | WebhookFragment | WebhookSetting(method=POST, webServer=https://iyuu.cn/IYUU15785T83034161cb23ec10d4291934c0**************.send, secret=, response=, webParams=text=告警通知&desp=<pre style="white-space:break-spaces;">[msg]</pre>, headers={}, proxyType=DIRECT, proxyHost=, proxyPort=, proxyAuthenticator=false, proxyUsername=, proxyPassword=)

2024-05-23 12:14:56.683 | I | WebhookUtils | matches = []

2024-05-23 12:14:56.683 | D | WebhookUtils | method = POST, Url = https://iyuu.cn/IYUU15785T83034161cb23ec10d4291934c0**************.send

2024-05-23 12:14:56.683 | I | WebhookUtils | requestUrl:https://iyuu.cn/IYUU15785T83034161cb23ec10d4291934c0**************.send

2024-05-23 12:14:56.688 | D | LoggingInterceptor | ------REQUEST------
At 2024-05-23 12:14:56

2024-05-23 12:14:56.689 | D | LoggingInterceptor | 	body:text=告警通知

2024-05-23 12:14:56.689 | D | LoggingInterceptor | --> POST https://iyuu.cn/IYUU15785T83034161cb23ec10d4291934c0**************.send http/1.1

2024-05-23 12:14:56.690 | D | LoggingInterceptor | --> END POST

2024-05-23 12:14:56.893 | D | LoggingInterceptor |  

2024-05-23 12:14:56.894 | D | LoggingInterceptor | 	date: Thu, 23 May 2024 04:14:57 GMT

2024-05-23 12:14:56.896 | D | LoggingInterceptor | ------RESPONSE------
At 2024-05-23 12:14:56

2024-05-23 12:14:56.898 | D | LoggingInterceptor | 	Cache-Control: no-cache

2024-05-23 12:14:56.899 | D | LoggingInterceptor | 	content-type: application/json

2024-05-23 12:14:56.899 | D | LoggingInterceptor | 	server: Tengine

2024-05-23 12:14:56.900 | D | LoggingInterceptor | 	strict-transport-security: max-age=31536000

2024-05-23 12:14:56.900 | D | LoggingInterceptor |  

2024-05-23 12:14:56.900 | D | LoggingInterceptor | <-- 200  https://iyuu.cn/IYUU15785T83034161cb23ec10d4291934c0**************.send (202 ms)

2024-05-23 12:14:56.901 | D | LoggingInterceptor | 	content-length: 37

2024-05-23 12:14:56.901 | D | LoggingInterceptor | 	body:{"errcode":0,"errmsg":"ok","data":[]}

2024-05-23 12:14:56.901 | D | LoggingInterceptor | <-- END HTTP

2024-05-23 12:14:56.904 | I | WebhookUtils | {"errcode":0,"errmsg":"ok","data":[]}

2024-05-23 12:15:01.542 | D | SettingsFragment | onGranted: permissions=[android.permission.RECEIVE_WAP_PUSH, android.permission.RECEIVE_MMS, android.permission.RECEIVE_SMS, android.permission.READ_SMS], all=true

提供解决方案

No response

通用设置 开 调试模式,导出日志贴上来看看

日志给出了,谢谢了

你的情况属于 2.2 webParams 非空,包含 [msg] 标签、不以 { 开头的 from=[from]&content=[content] 形式提供表单节点 (参见wiki

webParams 要求的是 key1=value1&key2=value2 形式

程序处理机制:

先按 & 分割,再按 = 分割,但是你的 value 包含了 = ,导致切割第二个键值对的时候出错了(具体看代码 WebhookUtils.kt 163行

解决方案:

要么,换成 json 形式 post 到 webhook

要么,style= 转义一下 style\u003d

好的,谢谢

经过尝试style= 转义style\u003d不行,接口不支持json格式

我的意思是你的 value2 需要自行 URLEncoder.encode(content, "UTF-8")

我顶多优化一下webParam分割键值对方式,剩下就看你的webhook能不能支持了

PS. 本次提交未经测试,仅在脑中跑了一边就提交了,请帮忙测试仔细点


覆盖安装 每周构建版 试试 (等待在线编译完成)

升级操作提示:

我试试

试了下还是不行,算了不加样式了,也是麻烦你了,感谢

试了下还是不行,算了不加样式了,也是麻烦你了,感谢

再贴一下你的日志看看

刚刚测试了下最新构建版本,不用转码=可以使用了,都正常了,模板内容不需要转码按正常填写就行,非常感谢!