Skip to content

Commit 6bcebd8

Browse files
committed
create input elements with attributes in a defined (sorted) order
1 parent 07636f2 commit 6bcebd8

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

roundup/cgi/templating.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ def _set_input_default_args(dic):
444444

445445
def cgi_escape_attrs(**attrs):
446446
return ' '.join(['%s="%s"'%(k,cgi.escape(str(v), True))
447-
for k,v in attrs.items()])
447+
for k,v in sorted(attrs.items())])
448448

449449
def input_html4(**attrs):
450450
"""Generate an 'input' (html4) element with given attributes"""

test/test_cgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ def hasPermission(s, p, classname=None, d=None, e=None, **kw):
801801
<p>deferred</p>
802802
<p>admin, anonymous</p>
803803
<p></p>
804-
<p><input type="text" name="superseder" value="5000" size="30"></p>
804+
<p><input name="superseder" size="30" type="text" value="5000"></p>
805805
</body>
806806
</html>
807807
""".strip ())

test/test_templating.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def test_string_plain_or_hyperlinked(self):
212212

213213
def test_string_field(self):
214214
p = StringHTMLProperty(self.client, 'test', '1', None, 'test', 'A string <b> with [email protected] embedded &lt; html</b>')
215-
self.assertEqual(p.field(), '<input type="text" name="test1@test" value="A string &lt;b&gt; with [email protected] embedded &amp;lt; html&lt;/b&gt;" size="30">')
215+
self.assertEqual(p.field(), '<input name="test1@test" size="30" type="text" value="A string &lt;b&gt; with [email protected] embedded &amp;lt; html&lt;/b&gt;">')
216216

217217
def test_string_multiline(self):
218218
p = StringHTMLProperty(self.client, 'test', '1', None, 'test', 'A string <b> with [email protected] embedded &lt; html</b>')

0 commit comments

Comments
 (0)