mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-28 16:28:01 -05:00
Drop extra whitespace in title on suggest/submit
This commit is contained in:
@@ -75,6 +75,7 @@ import csv
|
||||
from collections import defaultdict
|
||||
from datetime import datetime, timedelta
|
||||
import hashlib
|
||||
import re
|
||||
import urllib
|
||||
import urllib2
|
||||
|
||||
@@ -377,8 +378,12 @@ class ApiController(RedditController, OAuth2ResourceController):
|
||||
if not c.user.gold or not hasattr(request.post, 'sendreplies'):
|
||||
sendreplies = kind == 'self'
|
||||
|
||||
# get rid of extraneous whitespace in the title
|
||||
cleaned_title = re.sub(r'\s+', ' ', request.post.title, flags=re.UNICODE)
|
||||
cleaned_title = cleaned_title.strip()
|
||||
|
||||
# well, nothing left to do but submit it
|
||||
l = Link._submit(request.post.title, url if kind == 'link' else 'self',
|
||||
l = Link._submit(cleaned_title, url if kind == 'link' else 'self',
|
||||
c.user, sr, ip, spam=c.user._spam, sendreplies=sendreplies)
|
||||
|
||||
if banmsg:
|
||||
|
||||
@@ -310,6 +310,9 @@ def extract_title(data):
|
||||
if to_trim and to_trim.end() < len(title) / 2:
|
||||
title = title[:-(to_trim.end())]
|
||||
|
||||
# get rid of extraneous whitespace in the title
|
||||
title = re.sub(r'\s+', ' ', title, flags=re.UNICODE)
|
||||
|
||||
return title.encode('utf-8').strip()
|
||||
|
||||
valid_schemes = ('http', 'https', 'ftp', 'mailto')
|
||||
|
||||
Reference in New Issue
Block a user