Closed lucaslo closed 6 years ago
Hi,
That is quite a weird bug indeed. could potentially be a bug with crypto
itself or with the signature sent back from facebook directly.
Either way, it's clearly weird. I wonder if either of them strips the characters out then encrypts. That could be something to try out.
If a solution is really hard to find, I wouldn't advise to just bypass the code as it makes the bot safer.
I'll try and have a play with it over the weekend and see what it could be.
Any updates on this issue?
Hey @jdwuarin Me and @lucaslo got around the problem by using a map of replacements.
const characterMapping = {
"á": "\\u00e1",
"à": "\\u00e0",
...
}
__verifyRequestSignature(req, res, buf) {
...
let bufString = buf.toString('utf8')
for(let char in characterMapping) {
bufString = bufString.replace(char, characterMapping[char])
}
const expectedHash = crypto.createHmac('sha1', this.credentials.fbAppSecret)
.update(bufString)
.digest('hex');
...
}
I basically followed the description on facebook about escaping some characters to unicode.
Do you think there is a better solution for this?
Hey @0tho, This looks like the proper solution. Thanks for that! If you create a pull request for it, I'll create a new release for it.
Ok, I will as soon as possible.
@lucaslo @0tho @jdwuarin Has this eventually been fixed? I am searching around the Internet, and I see that many facebook bots have a similar problem.
Hey @balazsorban44, it has been some time so I don't remember all the details, but if I remember correctly we had an nginx route acting as a proxy that was messing with the encoding (or something like that). Using the code from my now closed PR helped for a while, but it was just a hack. I would recommend looking into your stack and finding what is messing with your encoding.
Hi! I have a bot that works perfectly except when I use a special character (like í ç ó ).
I've nailed it down to this piece of code.
I do have a code to remove those charactes, but the error is thrown before any middleware (or me having access to the text). Can anybody offer me a solution to this problem? Is there a workarround?