Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: Users

How to convert characters that have special meaning in HTML to HTML character entities

 

 

Zope users RSS feed   Index | Next | Previous | View Threaded


jb012b8598 at blueyonder

Apr 6, 2006, 5:18 AM

Post #1 of 4 (1090 views)
Permalink
How to convert characters that have special meaning in HTML to HTML character entities

Hi All,

I have a string that contains a <a
href="http://www.mywebaddress.com">link</a> tag that I would like rendered
as HTML when output but it only seems to render in the html page like this
&lt;a href="http://www.mywebaddress.com"&gt;link&lt;/a&gt;

To replace the characters, I tried this in my TAL:

<tal:block tal:define="d_stand row/STANDFIRST | nothing;
d_stand_replaced_chars python: (str(d_stand)).replace('&gt;','>');">

<p tal:condition="d_stand_replaced_chars"
tal:content="d_stand_replaced_chars" />
</tal:block>

But it converted the '&gt;' I replaced with a '>' back to a '&gt;' upon
rendering the string in a html page.

Any ideas how I can achieve this?

Jon




_______________________________________________
Zope maillist - Zope [at] zope
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )


maxm at mxm

Apr 6, 2006, 5:23 AM

Post #2 of 4 (1045 views)
Permalink
Re: How to convert characters that have special meaning in HTML to HTML character entities [In reply to]

Jonathan Bowlas wrote:
> Hi All,
>
> I have a string that contains a <a
> href="http://www.mywebaddress.com">link</a> tag that I would like rendered
> as HTML when output but it only seems to render in the html page like this
> &lt;a href="http://www.mywebaddress.com"&gt;link&lt;/a&gt;
>
> To replace the characters, I tried this in my TAL:
>
> <tal:block tal:define="d_stand row/STANDFIRST | nothing;
> d_stand_replaced_chars python: (str(d_stand)).replace('&gt;','>');">
>
> <p tal:condition="d_stand_replaced_chars"
> tal:content="d_stand_replaced_chars" />
> </tal:block>
>
> But it converted the '&gt;' I replaced with a '>' back to a '&gt;' upon
> rendering the string in a html page.
>
> Any ideas how I can achieve this?

tal:content="structure d_stand_replaced_chars"

--

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science

Phone: +45 66 11 84 94
Mobile: +45 29 93 42 96

_______________________________________________
Zope maillist - Zope [at] zope
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )


mj at zopatista

Apr 6, 2006, 5:24 AM

Post #3 of 4 (1051 views)
Permalink
Re: How to convert characters that have special meaning in HTML to HTML character entities [In reply to]

On 4/6/06, Jonathan Bowlas <jb012b8598 [at] blueyonder> wrote:
> I have a string that contains a <a
> href="http://www.mywebaddress.com">link</a> tag that I would like rendered
> as HTML when output but it only seems to render in the html page like this
> &lt;a href="http://www.mywebaddress.com"&gt;link&lt;/a&gt;
>
> To replace the characters, I tried this in my TAL:
>
> <tal:block tal:define="d_stand row/STANDFIRST | nothing;
> d_stand_replaced_chars python: (str(d_stand)).replace('&gt;','>');">
>
> <p tal:condition="d_stand_replaced_chars"
> tal:content="d_stand_replaced_chars" />
> </tal:block>
>
> But it converted the '&gt;' I replaced with a '>' back to a '&gt;' upon
> rendering the string in a html page.

TAL escapes characters that have special meaning in HTML or XML by
default, to avoid XSS attacks. You can force TAL to not do this with
the 'structure' keyword, like so:

<span tal:replace="structure
string:&lt;blink&gt;Blinking&lt;/blink&gt;">Not blinking</span>

--
Martijn Pieters


jb012b8598 at blueyonder

Apr 6, 2006, 5:31 AM

Post #4 of 4 (1048 views)
Permalink
RE: How to convert characters that have special meaning in HTML to HTML character entities [In reply to]

Whoa, speedy response! Thanks a lot, although I should've known this. <beats
self around head>

-----Original Message-----
From: Max M [mailto:maxm [at] mxm]
Sent: 06 April 2006 13:24
To: public-me-NUjxgDMnZEaakBO8gow8eQ [at] ciao
Subject: Re: How to convert characters that have special meaning in HTML to
HTML character entities



Jonathan Bowlas wrote:
> Hi All,
>
> I have a string that contains a <a
> href="http://www.mywebaddress.com">link</a> tag that I would like rendered
> as HTML when output but it only seems to render in the html page like this
> &lt;a href="http://www.mywebaddress.com"&gt;link&lt;/a&gt;
>
> To replace the characters, I tried this in my TAL:
>
> <tal:block tal:define="d_stand row/STANDFIRST | nothing;
> d_stand_replaced_chars python: (str(d_stand)).replace('&gt;','>');">
>
> <p tal:condition="d_stand_replaced_chars"
> tal:content="d_stand_replaced_chars" />
> </tal:block>
>
> But it converted the '&gt;' I replaced with a '>' back to a '&gt;' upon
> rendering the string in a html page.
>
> Any ideas how I can achieve this?

tal:content="structure d_stand_replaced_chars"

--

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science

Phone: +45 66 11 84 94
Mobile: +45 29 93 42 96



_______________________________________________
Zope maillist - Zope [at] zope
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )

Zope users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.