UMBRACO_GETITEM HTML encode Options
Ruben
Posted: Friday, February 08, 2008 8:21:46 PM

Rank: Devotee

Joined: 12/21/2007
Posts: 77
Location: Belgium
Is there currently a way to HTML escape a field?

We can do this for URLs:

<?UMBRACO_GETITEM field="MyField" urlEncode="true" />

But what to do with HTML?

If the feature's not there, should it be implemented?

Core Team Member | Test the new Umbraco data layer with MySQL support, download the latest source.
drobar
Posted: Friday, February 08, 2008 9:12:48 PM

Rank: Umbracoholic

Joined: 9/8/2006
Posts: 1,082
Location: KY, USA
Hi, Ruben,

I don't understand the question or what you're trying to do. Can you explain a bit more?

cheers,
doug.

MVP 2007/2008 - Official Umbraco Trainer for North America - Percipient Studios
Ruben
Posted: Friday, February 08, 2008 9:16:41 PM

Rank: Devotee

Joined: 12/21/2007
Posts: 77
Location: Belgium
Hi Douglas,

Suppose the field test has contents this & that.

Then:

<?UMBRACO_GETITEM field="MyField" /> gives this & that
<?UMBRACO_GETITEM field="MyField" urlEncode="true" /> gives this%20%26%20that

But what I want is this &amp; that. Is this possible with the UMBRACO_GETITEM tag?

Ruben

Core Team Member | Test the new Umbraco data layer with MySQL support, download the latest source.
drobar
Posted: Friday, February 08, 2008 9:32:27 PM

Rank: Umbracoholic

Joined: 9/8/2006
Posts: 1,082
Location: KY, USA
Thanks, now I understand.

I don't know of a way to alter GET_ITEM's output beyond what you've shown. But, as you've seen, the URL encoding is just that... the encoding needed for urls. Which isn't the same thing as that needed for html and you shouldn't expect it to know the difference.

Doing html encoding is something that TinyMCE and "tidy" do automatically for text you put in a rich text editor. But if you type it into a regular text field... well, you get out exactly what you put in.

Depending on what you're ultimately trying to accomplish, you might use xslt to produce the output and look into the umbraco.library:Tidy('String StringToTidy', 'Boolean LiveEditing') function.


As to your original question, "is it a missing feature?" I'd say yes and no. Yes, it is a feature that could be added directly on the GET_ITEM dialog next to the url encode checkbox. But no, in that one of the strengths of umbraco is that it isn't overly feature laden... just enough to do the job. And there are two ways to do this job already (use an RTE for html data input which will automatically produce html-encoded output, or use an xslt macro to convert raw text on the fly).

Does that make sense?

cheers,
doug.

MVP 2007/2008 - Official Umbraco Trainer for North America - Percipient Studios
Ruben
Posted: Friday, February 08, 2008 9:35:27 PM

Rank: Devotee

Joined: 12/21/2007
Posts: 77
Location: Belgium
Yes, thanks Douglas.

But I believe it's a missing feature: you could argue the same thing for URL encoding. I think a simple htmlEncode attribute wouldn't do any harm. I will take a look at this soon.

Thanks!

Core Team Member | Test the new Umbraco data layer with MySQL support, download the latest source.
Ruben
Posted: Saturday, March 08, 2008 9:14:02 PM

Rank: Devotee

Joined: 12/21/2007
Posts: 77
Location: Belgium
Finally got some time to work on this. Implemented in Changeset 31507.

Maybe it should even be on by default, as it is an XHTML issue as well as a security issue (script injection).

Core Team Member | Test the new Umbraco data layer with MySQL support, download the latest source.
dawoe
Posted: Friday, April 11, 2008 11:10:54 AM

Rank: Aficionado

Joined: 1/19/2008
Posts: 124
Location: Belgium
Ruben wrote:
Finally got some time to work on this. Implemented in Changeset 31507.

Maybe it should even be on by default, as it is an XHTML issue as well as a security issue (script injection).


Untill there is a version that contains this fix I've created a macro for this. You can find it at my blog.

Converting a DotNetNuke site to Umbraco : Follow it here
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.