Textpattern Forum

You are not logged in. Register | Login | Help

#1 2012-07-31 16:08:37

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 4,821
Website

[SOLVED] ampersands in urls and validation

I would like to link to a particular url with an ampersand in it. The url is

http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=13140

As we know the above causes xhtml to fail. I have tried

http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=13140,
http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=13140
and
http://mitpress.mit.edu/catalog/item/default.asp?ttype=2\x26tid=13140

but the page returns the following error

Microsoft VBScript runtime error ‘800a000d’
Type mismatch: ‘aEditionDetails’
/catalog/item/default.asp, line 1452

Can anyone suggest a valid xhtml alternative?


Yiannis
——————————
neme.org | neme-imca.org | hblack.net | LABS

Offline

#2 2012-07-31 16:19:29

Gocom
Developer
Registered: 2006-07-14
Posts: 4,403
Website

Re: [SOLVED] ampersands in urls and validation

There you go:

Illusions in Motion

Code:

<a href="http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&amp;tid=13140">
	Illusions in Motion
</a>

Or in Textile:

"Illusions in Motion":http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=13140

Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Offline

#3 2012-07-31 16:28:01

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 4,821
Website

Re: [SOLVED] ampersands in urls and validation

Hi Jukka,

I am using custom_filelds, not textile and when I type http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&amp;tid=13140 it returns the error above. Try to go to it and you will see.


Yiannis
——————————
neme.org | neme-imca.org | hblack.net | LABS

Offline

#4 2012-07-31 16:31:37

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 4,821
Website

Re: [SOLVED] ampersands in urls and validation

Looking at it again, it is strange. Using textile the ampersand is encoded the the link does go there (from this forum), but without the textile, ie using

<a href="http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&amp;tid=13140">
	Illusions in Motion
</a>

the link returns the error page.


Yiannis
——————————
neme.org | neme-imca.org | hblack.net | LABS

Offline

#5 2012-07-31 16:48:10

Gocom
Developer
Registered: 2006-07-14
Posts: 4,403
Website

Re: [SOLVED] ampersands in urls and validation

colak wrote:

I am using custom_filelds, not textile and when I type http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&amp;tid=13140

Custom fields already do escaping for you. Please see escape attribute. The following generates valid HTML when the custom field contains http://example.com/?foo=1&bar=1:

<a href="<txp:custom_field name="publisher_link" />">
	<txp:custom_field name="publisher_link" />
</a>

If you need to use HTML within a custom_field itself, set the escaping off (escape="").

Last edited by Gocom (2012-07-31 16:49:58)


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Offline

#6 2012-07-31 17:24:04

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 4,821
Website

Re: [SOLVED] ampersands in urls and validation

Gocom wrote:

Custom fields already do escaping for you.

Indeed they do and I did have the escape attribute but forgot about it so I was adding the amp; after the & which is what was messing up the url destination. Thanks Jukka. Problem solved.


Yiannis
——————————
neme.org | neme-imca.org | hblack.net | LABS

Offline

Board footer

Powered by FluxBB