Mercurial > p > roundup > code
diff roundup/cgi/client.py @ 1254:77920c42aeb9
Expose the tracker config as a variable for templating
Homogenise newlines in CGI text submissions [SF#614072]
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 09 Oct 2002 01:00:41 +0000 |
| parents | 209a47ede743 |
| children | a9a3c378acc2 |
line wrap: on
line diff
--- a/roundup/cgi/client.py Tue Oct 08 07:28:34 2002 +0000 +++ b/roundup/cgi/client.py Wed Oct 09 01:00:41 2002 +0000 @@ -1,4 +1,4 @@ -# $Id: client.py,v 1.51 2002-10-08 04:11:17 richard Exp $ +# $Id: client.py,v 1.52 2002-10-09 01:00:40 richard Exp $ __doc__ = """ WWW request handler (also used in the stand-alone server). @@ -1033,7 +1033,8 @@ # in a nutshell, don't do anything if there's no note or there's no # NOSY if self.form.has_key(':note'): - note = self.form[':note'].value.strip() + # fix the CRLF/CR -> LF stuff + note = fixNewlines(self.form[':note'].value.strip()) if not note: return None, files if not props.has_key('messages'): @@ -1105,6 +1106,15 @@ link = self.db.classes[link] link.set(nodeid, **{property: nid}) +def fixNewlines(text): + ''' Homogenise line endings. + + Different web clients send different line ending values, but + other systems (eg. email) don't necessarily handle those line + endings. Our solution is to convert all line endings to LF. + ''' + text = text.replace('\r\n', '\n') + return text.replace('\r', '\n') def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')): ''' Pull properties for the given class out of the form. @@ -1144,6 +1154,8 @@ if isinstance(proptype, hyperdb.String): if not value: continue + # fix the CRLF/CR -> LF stuff + value = fixNewlines(value) elif isinstance(proptype, hyperdb.Password): if not value: # ignore empty password values
