From bc4a9e7c960a5cf8d0e3b3c395e671a8d7e3d0da Mon Sep 17 00:00:00 2001 From: Chad Birch Date: Fri, 22 Feb 2013 16:05:42 -0700 Subject: [PATCH] Don't trim off over half of a suggested title --- r2/r2/lib/utils/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/r2/r2/lib/utils/utils.py b/r2/r2/lib/utils/utils.py index 83efa4f23..9893bb81e 100644 --- a/r2/r2/lib/utils/utils.py +++ b/r2/r2/lib/utils/utils.py @@ -305,7 +305,9 @@ def extract_title(data): to_trim = re.search(u'\s[\u00ab\u00bb\u2013\u2014|-]\s', reverse_title, flags=re.UNICODE) - if to_trim: + + # only trim if it won't take off over half the title + if to_trim and to_trim.end() < len(title) / 2: title = title[:-(to_trim.end())] return title.encode('utf-8').strip()