Added normalization of draft title extracted from submitted XML.

- Legacy-Id: 17119
This commit is contained in:
Henrik Levkowetz 2019-12-02 16:24:51 +00:00
parent 0a9cea598e
commit ac6b664fa5
2 changed files with 3 additions and 1 deletions

View file

@ -48,6 +48,7 @@ from ietf.submit.parsers.ps_parser import PSParser
from ietf.submit.parsers.xml_parser import XMLParser
from ietf.utils import log
from ietf.utils.draft import Draft
from ietf.utils.text import normalize_text
class SubmissionBaseUploadForm(forms.Form):
xml = forms.FileField(label='.xml format', required=True)
@ -204,6 +205,7 @@ class SubmissionBaseUploadForm(forms.Form):
self.title = self.xmlroot.findtext('front/title').strip()
if type(self.title) is six.text_type:
self.title = unidecode(self.title)
self.title = normalize_text(self.title)
self.abstract = (self.xmlroot.findtext('front/abstract') or '').strip()
if type(self.abstract) is six.text_type:
self.abstract = unidecode(self.abstract)

View file

@ -195,4 +195,4 @@ def unwrap(s):
return s.replace('\n', ' ')
def normalize_text(s):
return s.replace(r'\s+', ' ').strip()
return re.sub(r'[\s\u2028\u2029\n\r]+', ' ', s).strip()