LiteLoaderQQNT-PGP-Encryption
LiteLoaderQQNT-PGP-Encryption copied to clipboard
更好的 PGP 加密消息的检测方法
目前是使用这种简单的检测方法:
https://github.com/TransparentLC/LiteLoaderQQNT-PGP-Encryption/blob/938b4d8b9bfef3b224a569e912669949de0bbe3a/src/renderer/index.ts#L41-L44
之前也在 https://github.com/TransparentLC/LiteLoaderQQNT-PGP-Encryption/issues/1#issuecomment-2531409584 考虑过使用一个更详细的正则表达式检测整个消息,但是发现可能会 ReDoS,所以也没有实装。
// 每一行后面有一个空格
`-----BEGIN PGP MESSAGE-----
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
=xxxx
-----END PGP MESSAGE----- `.match(/^-----BEGIN PGP MESSAGE-----\s*(?:.+?:.*\n)*\s*\n(?:[A-Za-z\d+\/]*\n?)*={0,2}\n=(?:[A-Za-z\d+\/]{4})?\n\s*-----END PGP MESSAGE-----\s*$/);