Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix qimei error -1 on Android #2753

Merged
merged 1 commit into from
Jul 26, 2023
Merged

Fix qimei error -1 on Android #2753

merged 1 commit into from
Jul 26, 2023

Conversation

zhaodice
Copy link
Contributor

@zhaodice zhaodice commented Jul 25, 2023

Base64居然敢自动换行!!直接导致qimei post 失败 error code -1 不解释!
#2752

会导致直接post以下内容(多出了可恶的\n):

{"key":"cKEwfBzaNDaW7k/1KvV612Lk857Zy6fNsBQnGioXLb6El0NB1daWh0N6daSOFuRH6w+BysDiMAuk\nRi5QpWyl1W0pOE32TswI1xii6ybp3DA2rpHwmBoaXYggDd7yG5IHIzaxwn6Y5rlqIRuGeoq9nOmg\nbtUc5QYoIWqrINH2CLY=\n","params":"AJoFBdx6izCswqsQUoR+zF1aQRaIg3fCrEpa2dNhdagm4zAoa1uyxCcLVzX/E8bD8tElS4zTMFJ3\nv0jGfbVxeIEWMvwcVTaxeLfzuPpbdrglqb2UnN/EsggsOzlF20ejqdhiWOEH/jugonPnPHdiJN3Q\nIMryE+AauV0batv5lXDSQFtUjXMxe0dkh2zrzMDEP7ptFcKDEY0DzzwXwx0DrrjvWwRtczqe4/fD\nMol0FFClQknqyjd2A2uqhgJqlV51o2RPY5FZaTFYiQbSxUJy+bUjm8i+/typ1+UFNHU2q2qt87Jb\nSAvnRbeZECV5hIFnhDh7RC45aphU4c+0mMHGemAiJTXXn+vax8i3Rvbc4E+hmjgiKLZv4GEW7HEy\nEkuI/WHTeL0y73uZi1UjE0m4+kkDO+10IPJDnEVOq0VEzipFWg/8khgYJIGxUN70skai/5ib/mZn\nbncrZlV3p6yTwIifQMjKfPa4kWgsoFpMCVCyfQAsELqXclNWxEmCwj1p2/Ox327+E08q/JT0TYWC\nQaNCiL6jTXE0B/Y/Gf9GOamBzGP3QBA+b0/R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1e5Zmk3MJhVQxOrfTuZHNiZCeFjjG22dsCzZQIViBpgMe1YueDagwb\nsxvHCdYgS5kDZlsWTMWXT54OIDH8KWxH/2SaPm4lcuvuid2mB1ucVzbNK9PtU/eYZodoL2G0vRno\ncY9zHEn36FNWXoQFY5zDXPFVqbyj5q6Ams9vz6NOoRqNiWCAF1y5c9+YKxrKX/FvY4ufQtTlwfwL\nfHG3W1XQNplsmzybBwTfQfOnYX41GAHGlqAAnzvrQGk9YhCGXYTOxGpBza7l+AIxwuDPHj8DLSxq\n4lavbB5sFOV0AtgdrUAUzleCx3nC75UV6puNjN793XQDXFquA+4786gZkvVakoseHu1mBFSIc/X1\nCip0um4lyHDj0FS2UNyRkJMhPldElKDwTyAQHMgEE6ZEHt45A7gJTsv9+Us6+fuDNrCqx9JyXBIC\ns7iVjegXEGfANjVQl0y/IA8I/kvzQoLXRvvONkFDA1BkbZKz9jGtPjSfaLQlWA0TFM7euh3RzobP\nw6jtK8CiJaYucg3Y8hDusOrDLlswxKnFmtFhiD97LyBZbkahkzQLC2Cs9293d3sPbKeb5Q==\n","time":1690310597000,"nonce":"FycTMTsxw81w6znz","sign":"F98132300FAD4A6FF4EA385FAF9CBE1F","extra":""}

本补丁将不允许base64编码时夹带换行符,也不允许带换行符的base64被解码(解码前需要提前替换\n),与瘟斗士平台保持一致

@mikko-mikust
Copy link

说实话不建议这么快pr的,这个函数有好几个地方都在用,你最好都试一下其他的地方有没有问题

@zhaodice
Copy link
Contributor Author

说实话不建议这么快pr的,这个函数有好几个地方都在用,你最好都试一下其他的地方有没有问题

这函数本身就不应该换行,windows平台就是没换行的,如果单纯去掉换行就出了问题...那windows平台应该早就出问题了

@zhaodice
Copy link
Contributor Author

经测试,安卓端一切正常:
image

qimei已经正常获取
image

@StageGuard

This comment was marked as resolved.

@zhaodice

This comment was marked as resolved.

@mikko-mikust
Copy link

mikko-mikust commented Jul 26, 2023

说实话不建议这么快pr的,这个函数有好几个地方都在用,你最好都试一下其他的地方有没有问题

这函数本身就不应该换行,windows平台就是没换行的,如果单纯去掉换行就出了问题...那windows平台应该早就出问题了

就是你应该也去测一下调用这个函数的其他地方(使用的地方很少其实),比如匿名群消息什么的,我觉得这个很可能本来也有问题

@StageGuard
Copy link
Member

你快把我 review 的改了

咋改,没看见什么东西啊?

抱歉忘了点 submit review ;v;

@zhaodice
Copy link
Contributor Author

你快把我 review 的改了

咋改,没看见什么东西啊?

抱歉忘了点 submit review ;v;

这样是否会导致不一致?因为windows平台的base64是没有换行的

@StageGuard
Copy link
Member

你快把我 review 的改了

咋改,没看见什么东西啊?

抱歉忘了点 submit review ;v;

这样是否会导致不一致?因为windows平台的base64是没有换行的

你测试一下(

@mikko-mikust
Copy link

mikko-mikust commented Jul 26, 2023

你快把我 review 的改了

咋改,没看见什么东西啊?

抱歉忘了点 submit review ;v;

这样是否会导致不一致?因为windows平台的base64是没有换行的
如果有问题的话估计调用函数的地方都要改一下来适应,qimei部分我觉得还没完全完善,比如写死了channelid

@zhaodice
Copy link
Contributor Author

fun main(args : Array<String>){
    println(java.util.Base64.getEncoder().encodeToString("1佛坪哼哼啊啊啊啊外人看来规划微软厉害了‘开了个好人与推理怕溜了人格与苹果·然后看完v可欧培亚航空,人【怕怕【更可怕融合给客人紧哦碰怕【;还不快来肉片啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊为我国·1opk-tfgm-423 投票去买全欧培儿歌看来人么和波兰取决于0 遇见50她以前吗,呕吐以加强亦哦v吗,53ioyb,奥胖同学,兼容问题迷哦吗加强哟怕".toByteArray()))
}

运行结果:

MeS9m+WdquWTvOWTvOWViuWViuWViuWViuWkluS6uueci+adpeinhOWIkuW+rui9r+WOieWus+S6huKAmOW8gOS6huS4quWlveS6uuS4juaOqOeQhuaAlea6nOS6huS6uuagvOS4juiLueaenMK354S25ZCO55yL5a6MduWPr+asp+WfueS6muiIquepuu+8jOS6uuOAkOaAleaAleOAkOabtOWPr+aAleiejeWQiOe7meWuouS6uue0p+WTpueisOaAleOAkO+8m+i/mOS4jeW/q+adpeiCieeJh+WViuWViuWViuWViuWViuWViuWViuWViuWViuWViuWViuWViuWViuWViuWViuS4uuaIkeWbvcK3MW9way10ZmdtLTQyMyDmipXnpajljrvkubDlhajmrKfln7nlhL/mrYznnIvmnaXkurrkuYjlkozms6LlhbDlj5blhrPkuo4wIOmBh+ingTUw5aW55Lul5YmN5ZCX77yM5ZGV5ZCQ5Lul5Yqg5by65Lqm5ZOmduWQl++8jDUzaW95Yu+8jOWlpeiDluWQjOWtpu+8jOWFvOWuuemXrumimOi/t+WTpuWQl+WKoOW8uuWTn+aAlQ==

没有出现换行,既然jvm原生都没有出现换行,安卓就没必要换行,所以NO_WRAP是可以的
总不能你这个mirai在jvm下base64不换行,在安卓下突然插个\n吧

@zhaodice
Copy link
Contributor Author

除非要换行都换行,绝对不能出现平台不同,编码结果不一样的情况

@StageGuard
Copy link
Member

除非要换行都换行,绝对不能出现平台不同,编码结果不一样的情况

那这样就没问题

@zhaodice
Copy link
Contributor Author

@StageGuard 我测过了,jvm下不会换行,测试代码在上面,不放心可以自己运行,jvm都不换行,android就没必要换行了吧,要保证行为一致呀

@StageGuard StageGuard merged commit d1295c4 into mamoe:dev Jul 26, 2023
1 check passed
@zhaodice zhaodice deleted the patch-2 branch July 26, 2023 05:29
@Karlatemp Karlatemp added this to the 2.16.0-RC milestone Jul 26, 2023
@Karlatemp Karlatemp added t:bug 类型: bug s:core 子系统: mirai-core labels Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s:core 子系统: mirai-core t:bug 类型: bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants