Re: Storing HTML: HTML entities being rendered in that raw form

From: Marco Colombo <pgsql(at)esiway(dot)net>
To: linnewbie <linnewbie(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Storing HTML: HTML entities being rendered in that raw form
Date: 2009-04-10 09:00:59
Message-ID: 49DF0ACB.3000508@esiway.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

linnewbie wrote:
> On Apr 9, 1:00 pm, st(dot)(dot)(dot)(at)blighty(dot)com (Steve Atkins) wrote:
>> On Apr 9, 2009, at 9:27 AM, linnewbie wrote:
>>
>>> Hi all,
>>> I have stored HTML in a text field that I subsequently render on the
>>> web. However when I retrieve and render this data on the web I am
>>> getting the entities being rendered in their raw form, ie, instead of
>>> getting the '&' symbol when '&amp;' is stored I'm getting the 'raw'
>>> '&amp;'.
>>> I would be grateful if anyone can point out how I can get around this.
>> It's a problem in your code, not the database. You're probably
>> escaping it one time to many or unescaping it one time too few.
>>
>> Cheers,
>> Steve
>>
>> --
>> Sent via pgsql-general mailing list (pgsql-gene(dot)(dot)(dot)(at)postgresql(dot)org)
>> To make changes to your subscription:http://www.postgresql.org/mailpref/pgsql-general
>
> To clarify, I am not escaping the string in any way.
>
> Say the page I am saving the database is the about us page form a
> company website.
> First, make a from to create the about us page in a text area field,
> then I copy the
> html from my text editor and past it ino this text area from. I then
> have a cgi script which
> takes the contents from the text area field and stores it in the
> database.
>
> What I have on disk would be:
>
> ................................
> ..............................
> <p> Bonnie &amp; Clyde</p>
>
> which would usually be rendered as:
>
> Bonnie & Clype
>
> but this is not happening, it's being rendered
> as:
>
> Bonnie &amp; Clyde

That's because, as someone else suggested, something is quoting the &.
In order to be rendered 'Bonnie &amp; Clyde' by the browser, it needs to be
'Bonnie &amp;amp; Clyde' in the HTML (just view the HTML source from inside
the browser).

You haven't provided any detail on the rendering phase, BTW.

.TM.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2009-04-10 09:31:45 Re: Evidently no support for the mmddyyyy date format
Previous Message Richard Huxton 2009-04-10 07:51:48 Re: Storing HTML: HTML entities being rendered in that raw form