~deimos/madcow-bot

ca458765373c1766cdf64dd9bede9cbcae949828 — Chris Jones 8 years ago df8185f
hotfix broken handling when there is emoji titles for scanned webpage previews
1 files changed, 18 insertions(+), 1 deletions(-)

M contrib/django-memebot/gruntle/memebot/scanner/__init__.py
M contrib/django-memebot/gruntle/memebot/scanner/__init__.py => contrib/django-memebot/gruntle/memebot/scanner/__init__.py +18 -1
@@ 255,7 255,24 @@ def run(logger, max_links=None, dry_run=False, user_agent=None, timeout=None, ma
                link.resolved_url = result.resolved_url
                link.content_type = result.content_type
                link.content = result.content
                link.title = result.title

                # XXX some seriously broken shit going on witih emoji combinatorials, hack to make the links flow again
                #link.title = result.title

                safe_title = result.title
                if safe_title is not None:
                    if not isinstance(safe_title, unicode):
                        if not isinstance(safe_title, str):
                            safe_title = str(safe_title)
                        safe_title = safe_title.decode('latin1')
                    safe_title = safe_title.encode('ascii', 'ignore')
                    safe_title = safe_title.decode('ascii')
                    safe_title = safe_title.strip()
                    if not safe_title:
                        safe_title = None

                link.title = safe_title

                link.scanner = scanner_name
                link.publish(commit=False)