Skip to content

Commit bd536c3

Browse files
author
Richard Jones
committed
fix StringHTMLProperty hyperlinking
1 parent e77e208 commit bd536c3

File tree

4 files changed

+60
-30
lines changed

4 files changed

+60
-30
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ are given with the most recent entry first.
1212
- cleaning old unused sessions only once per hour, not on every cgi
1313
request. It is greatly improves web interface performance, especially
1414
on trackers under high load
15+
- fix StringHTMLProperty hyperlinking
1516

1617
2003-??-?? 0.5.5
1718
- fixed rdbms searching by ID (sf bug 666615)
1819
- detect corrupted index and raise semi-useful exception (sf bug 666767)
1920
- open server logfile unbuffered
21+
- revert StringHTMLProperty to not hyperlink text by default
2022

2123

2224
2003-01-10 0.5.4

doc/customizing.txt

Lines changed: 53 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Customising Roundup
33
===================
44

5-
:Version: $Revision: 1.70 $
5+
:Version: $Revision: 1.71 $
66

77
.. This document borrows from the ZopeBook section on ZPT. The original is at:
88
http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx
@@ -1247,32 +1247,58 @@ _value the value of the property if any - this is the actual value
12471247

12481248
There are several methods available on these wrapper objects:
12491249

1250-
=========== =================================================================
1251-
Method Description
1252-
=========== =================================================================
1253-
plain render a "plain" representation of the property
1254-
field render an appropriate form edit field for the property - for most
1255-
types this is a text entry box, but for Booleans it's a tri-state
1256-
yes/no/neither selection.
1257-
stext only on String properties - render the value of the
1258-
property as StructuredText (requires the StructureText module
1259-
to be installed separately)
1260-
multiline only on String properties - render a multiline form edit
1261-
field for the property
1262-
email only on String properties - render the value of the
1263-
property as an obscured email address
1264-
confirm only on Password properties - render a second form edit field for
1265-
the property, used for confirmation that the user typed the
1266-
password correctly. Generates a field with name "name:confirm".
1267-
reldate only on Date properties - render the interval between the
1268-
date and now
1269-
pretty only on Interval properties - render the interval in a
1270-
pretty format (eg. "yesterday")
1271-
menu only on Link and Multilink properties - render a form select
1272-
list for this property
1273-
reverse only on Multilink properties - produce a list of the linked
1274-
items in reverse order
1275-
=========== =================================================================
1250+
========= =====================================================================
1251+
Method Description
1252+
========= =====================================================================
1253+
plain render a "plain" representation of the property. This method may
1254+
take two arguments:
1255+
1256+
escape
1257+
If true, escape the text so it is HTML safe (default: no). The
1258+
reason this defaults to off is that text is usually escaped
1259+
at a later stage by the TAL commands, unless the "structure"
1260+
option is used in the template. The following are all equivalent::
1261+
1262+
<p tal:content="structure python:msg.content.plain(escape=1)" />
1263+
<p tal:content="python:msg.content.plain()" />
1264+
<p tal:content="msg/content/plain" />
1265+
<p tal:content="msg/content" />
1266+
1267+
Usually you'll only want to use the escape option in a complex
1268+
expression.
1269+
1270+
hyperlink
1271+
If true, turn URLs, email addresses and hyperdb item designators
1272+
in the text into hyperlinks (default: no). Note that you'll need
1273+
to use the "structure" TAL option if you want to use this::
1274+
1275+
<p tal:content="structure python:msg.content.plain(hyperlink=1)" />
1276+
1277+
Note also that the text is automatically HTML-escape before the
1278+
hyperlinking transformation.
1279+
1280+
field render an appropriate form edit field for the property - for most
1281+
types this is a text entry box, but for Booleans it's a tri-state
1282+
yes/no/neither selection.
1283+
stext only on String properties - render the value of the
1284+
property as StructuredText (requires the StructureText module
1285+
to be installed separately)
1286+
multiline only on String properties - render a multiline form edit
1287+
field for the property
1288+
email only on String properties - render the value of the
1289+
property as an obscured email address
1290+
confirm only on Password properties - render a second form edit field for
1291+
the property, used for confirmation that the user typed the
1292+
password correctly. Generates a field with name "name:confirm".
1293+
reldate only on Date properties - render the interval between the
1294+
date and now
1295+
pretty only on Interval properties - render the interval in a
1296+
pretty format (eg. "yesterday")
1297+
menu only on Link and Multilink properties - render a form select
1298+
list for this property
1299+
reverse only on Multilink properties - produce a list of the linked
1300+
items in reverse order
1301+
========= =====================================================================
12761302

12771303
The request variable
12781304
~~~~~~~~~~~~~~~~~~~~

roundup/cgi/templating.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ def _designator_repl(self, match):
786786
except KeyError:
787787
return '%s%s'%(s1, s2)
788788

789-
def plain(self, escape=0, hyperlink=1):
789+
def plain(self, escape=0, hyperlink=0):
790790
''' Render a "plain" representation of the property
791791
792792
"escape" turns on/off HTML quoting
@@ -798,8 +798,10 @@ def plain(self, escape=0, hyperlink=1):
798798
if escape:
799799
s = cgi.escape(str(self._value))
800800
else:
801-
s = self._value
801+
s = str(self._value)
802802
if hyperlink:
803+
if not escape:
804+
s = cgi.escape(s)
803805
s = self.url_re.sub(self._url_repl, s)
804806
s = self.email_re.sub(self._email_repl, s)
805807
s = self.designator_re.sub(self._designator_repl, s)

roundup/templates/classic/html/issue.item

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ python:db.user.classhelp('username,realname,address,phone')" /><br>
140140
</tr>
141141
<tr>
142142
<td colspan="4" class="content">
143-
<pre tal:content="structure msg/content">content</pre>
143+
<pre tal:content="msg/content">content</pre>
144144
</td>
145145
</tr>
146146
</tal:block>

0 commit comments

Comments
 (0)