comparison 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
comparison
equal deleted inserted replaced
1253:fe67477e678f 1254:77920c42aeb9
1 # $Id: client.py,v 1.51 2002-10-08 04:11:17 richard Exp $ 1 # $Id: client.py,v 1.52 2002-10-09 01:00:40 richard Exp $
2 2
3 __doc__ = """ 3 __doc__ = """
4 WWW request handler (also used in the stand-alone server). 4 WWW request handler (also used in the stand-alone server).
5 """ 5 """
6 6
1031 props = cl.getprops() 1031 props = cl.getprops()
1032 note = None 1032 note = None
1033 # in a nutshell, don't do anything if there's no note or there's no 1033 # in a nutshell, don't do anything if there's no note or there's no
1034 # NOSY 1034 # NOSY
1035 if self.form.has_key(':note'): 1035 if self.form.has_key(':note'):
1036 note = self.form[':note'].value.strip() 1036 # fix the CRLF/CR -> LF stuff
1037 note = fixNewlines(self.form[':note'].value.strip())
1037 if not note: 1038 if not note:
1038 return None, files 1039 return None, files
1039 if not props.has_key('messages'): 1040 if not props.has_key('messages'):
1040 return None, files 1041 return None, files
1041 if not isinstance(props['messages'], hyperdb.Multilink): 1042 if not isinstance(props['messages'], hyperdb.Multilink):
1103 designator, property = value.split(':') 1104 designator, property = value.split(':')
1104 link, nodeid = hyperdb.splitDesignator(designator) 1105 link, nodeid = hyperdb.splitDesignator(designator)
1105 link = self.db.classes[link] 1106 link = self.db.classes[link]
1106 link.set(nodeid, **{property: nid}) 1107 link.set(nodeid, **{property: nid})
1107 1108
1109 def fixNewlines(text):
1110 ''' Homogenise line endings.
1111
1112 Different web clients send different line ending values, but
1113 other systems (eg. email) don't necessarily handle those line
1114 endings. Our solution is to convert all line endings to LF.
1115 '''
1116 text = text.replace('\r\n', '\n')
1117 return text.replace('\r', '\n')
1108 1118
1109 def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')): 1119 def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')):
1110 ''' Pull properties for the given class out of the form. 1120 ''' Pull properties for the given class out of the form.
1111 1121
1112 If a ":required" parameter is supplied, then the names property values 1122 If a ":required" parameter is supplied, then the names property values
1142 value = value.value.strip() 1152 value = value.value.strip()
1143 1153
1144 if isinstance(proptype, hyperdb.String): 1154 if isinstance(proptype, hyperdb.String):
1145 if not value: 1155 if not value:
1146 continue 1156 continue
1157 # fix the CRLF/CR -> LF stuff
1158 value = fixNewlines(value)
1147 elif isinstance(proptype, hyperdb.Password): 1159 elif isinstance(proptype, hyperdb.Password):
1148 if not value: 1160 if not value:
1149 # ignore empty password values 1161 # ignore empty password values
1150 continue 1162 continue
1151 if not form.has_key('%s:confirm'%key): 1163 if not form.has_key('%s:confirm'%key):

Roundup Issue Tracker: http://roundup-tracker.org/