From 4793aaf5e60f09735327f7b803458fa17c440e47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Cort=C3=A9z?= Date: Fri, 24 Feb 2017 09:51:39 -0600 Subject: [PATCH] Convert HTML entities to unicode in long tweets. Fixes #118 --- doc/changelog.md | 1 + src/long_tweets/twishort.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/changelog.md b/doc/changelog.md index 4828a32f..c19f77d8 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -8,6 +8,7 @@ * TWBlue shows an error message when you try to view the profile of an user that does not exist or has been suspended. ([#114,](https://github.com/manuelcortez/TWBlue/issues/114) [#115](https://github.com/manuelcortez/TWBlue/issues/115)) * The spellchecker module should select the right language when is set to "user default". ([#117](https://github.com/manuelcortez/TWBlue/issues/117)) * Image description will be displayed in retweets too. ([#119](https://github.com/manuelcortez/TWBlue/issues/119)) +* When reading a long tweet, you shouldn't read strange entities anymore. ([#118](https://github.com/manuelcortez/twblue/issues/118)) ## Changes in version 0.88 and 0.89 diff --git a/src/long_tweets/twishort.py b/src/long_tweets/twishort.py index 1b304f33..32ed516f 100644 --- a/src/long_tweets/twishort.py +++ b/src/long_tweets/twishort.py @@ -55,7 +55,11 @@ def is_long(tweet): def get_full_text(uri): try: r = requests.get("http://api.twishort.com/1.1/get.json", params={"uri": uri, "api_key": keys.keyring.get("twishort_api_key")}) - return r.json()["text"] + msg = r.json()["text"] + # Try to parse possible HTML entities. + from twitter.compose import StripChars + msg = StripChars(msg) + return msg except: return False