I'm trying to change my Wi-Fi SSID to be an emoji, but the web UI doesn't allow it. Instead, I capture a valid PUT request to the router's API, copy it as a fetch
call using Chrome's Dev Tools, change the SSID to an emoji, and replay the request. It works great.
However, when I try to do it using Python Requests, it escapes the emoji () to the corresponding JavaScript escapes:
\uD83E\uDD20
. When this gets sent along to the router, it somehow gets translated to >
(a greater than sign followed by a space). This is frustrating because I'd assume that both methods would encode the emoji the same way.
Since it works with JavaScript's fetch
, there must be some difference in the way the message or the emoji is being encoded.
Fetch Call: (emoji just shows up as the emoji, even when inspecting the request with Dev Tools) (edited for brevity)
fetch("https://192.168.1.1/api/wireless", {
"credentials": "omit",
"headers": {
"accept": "application/json, text/plain, */*",
"content-type": "application/json;charset=UTF-8",
"x-xsrf-token": "[The token for this login session]"
},
"referrer": "https://192.168.1.1/",
"referrerPolicy": "no-referrer-when-downgrade",
"body": "{
\"wifi\": [{
\"boring key 1\": \"boring value\",
\"boring key 2\": \"boring value\",
\"ssid\": \"\",
\"boring key 3\": \"boring value\",
\"boring key 4\": \"boring value\"
}]
}",
"method": "PUT",
"mode": "cors"
});
Requests Call: (edited for brevity)
res = session.put('https://192.168.1.1/api/wireless',
verify=False,
json={
"wifi":[{
"boring key 1":"boring value",
"boring key 2":"boring value",
"ssid":"",
"boring key 3":
"boring value",
"boring key 4":"boring value"
}]
})
So what's the difference in the way they're being encoded? And how can I see what fetch's actual output is? (Dev Tools just shows an emoji, no escape sequences.)