Created
August 1, 2016 06:50
-
-
Save anroots/8482abe6af9153df0e4a9a5269fca345 to your computer and use it in GitHub Desktop.
Proof that Fleep handles UTF-8 correctly in conversation topics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Proof that Fleep handles UTF-8 strings correctly | |
# and does not sanitize input into ASCII-only strings | |
# | |
# You'll need to create a conversation with UTF-8 characters | |
# in the topic, then filter this conversation out | |
# in the code below. | |
import requests | |
import json | |
print "Logging into Fleep via API..." | |
r = requests.post("https://fleep.io/api/account/login", | |
headers = {"Content-Type": "application/json"}, | |
data = json.dumps({"email": "[email protected]", "password": 'dadada'})) | |
ticket = r.json()["ticket"] | |
token_id = r.cookies["token_id"] | |
print "Connected. Listing all conversation topics..." | |
r = requests.post("https://fleep.io/api/conversation/list", | |
headers = {"Content-Type": "application/json"}, | |
cookies = {"token_id": token_id}, | |
data = json.dumps({"sync_horizon": 0, "ticket": ticket})) | |
print "OK. Searching for our conversation..." | |
for conv in r.json()['conversations']: | |
if 'Cloud' in conv['topic']: | |
print "Found topic 'Cloud, Oops'. Dumping the topic as character codes:" | |
print "" | |
print conv['topic'] | |
print "-----------" | |
for c in conv['topic']: | |
print repr(c), ord(c) | |
print "" | |
print "Found UTF character '65279' (ZERO WIDTH NO-BREAK SPACE, U+FEFF) in the topic!" | |
print "Conclusion: Fleep does UTF RIGHT and does not 'sanitize' strings into ASCII. Now go, troll your friends." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment