how to handle a " & " in a form textbox

tokenring 19 May, 2010
I was looking around the forums and I couldn't find out exactly how to do this. It might not even be something I can do on my end.

Bob, you might remember this as you help me setup the forms I used for this. Basically a user is submitting this text to my form

http://preview.traxsource.com/files/previews/nctgd038-3261--1-we_love_house--dave_floyd_&_pook-p.mp3


but it shows up until the character before the &

http://preview.traxsource.com/files/previews/nctgd038-3261--1-we_love_house--dave_floyd_


all strings/urls I receive with the &, gets cut off at that char.


Aaron
GreyHead 20 May, 2010
Hi Aaron,

It depends on where they are being cut off. Checking that may take a little detective work.

Looking on Wikipedia http://en.wikipedia.org/wiki/Filename

Note 1: Most Unix shells require certain characters such as spaces, <, >, |, \, and sometimes :, (, ), &, ;, as well as wildcards such as ? and *, to be quoted or escaped:



So if the file is being uploaded OK then you probably need to rename it.

If it's not being uploaded correctly then there isn't much you can do except ask the users to use 'better' file names.

Bob
tokenring 21 May, 2010
They are just sending me the link, and are not actually submitting a file. These are URLs and according to RFC, they are compliant. I have checked this myself. RFC 1738. The 3rd party who is formatting the string is a very high end website.

Aaron
GreyHead 21 May, 2010
Hi Aaron,

Reserved:

Many URL schemes reserve certain characters for a special meaning:
their appearance in the scheme-specific part of the URL has a
designated semantics. If the character corresponding to an octet is
reserved in a scheme, the octet must be encoded. The characters ";",
"/", "?", ":", "@", "=" and "&" are the characters which may be
reserved for special meaning within a scheme. No other characters may
be reserved within a scheme.

Read more: http://www.faqs.org/rfcs/rfc1738.html#ixzz0oYvzBJi1


Bob
tokenring 22 May, 2010
Hey Bob,

I'm not sure what you are getting at here in this last post. The URL is completely valid and regardless of it's validity... the form shouldn't being the GATEKEEPER of the URL formatting. How ever that text is passed to me or not, she be delivered the way as it is sent.

The browser on the other hand will determine *what should I do* with this malformed URL, not the form. The form needs to pass it as it comes and that is what the issue is.

Aaron
GreyHead 22 May, 2010
Hi Aaron,

I'm sorry, I misunderstood your earlier post. The fact that it's a URL -- invalid or not -- is irrelevant if you are just saving a text string from an input.

I've just checked with a test form and ChronoForms has no problem with that url-string. It's saved to the database and added to an email exactly as it should be.

Bob
tokenring 22 May, 2010
Thanks Bob! :-)

Aaron
tokenring 22 May, 2010
do you see anything wrong with?

<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label" style="width: 150px;">Audio clip:</label>
<input class="cf_inputbox required validate-url" maxlength="200" size="30" title="Link to the audio clip on Choicetrax" id="text_9" name="urls" type="text" value='<?php echo $audio_clip; ?>' />
<a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" alt="" src="components/com_chronocontact/css/images/tooltip.png"/></a>
<div class="tooltipdiv">Audio clip: :: URL to the audio clip</div>
</div>
<div class="cfclear"> </div>
</div>
nml375 22 May, 2010
Hi,
This sounds, to me, as if the browser does not properly encode the form data before sending the POST data block.
Do you experience any issues with extended charsets (I.E. umlauts: å, ä, ö and similar)?

/Fredrik
tokenring 24 May, 2010
what browser are you talking about? The client browser? If so, they are using all type of browsers and platforms. In testing I went to the site that I'm using and I went to add the track to another site (not mine) and the file turned up broken there too. It was cut-off at the & symbol.

This from the site:

<b>
is the link getting from my site to yours correctly? if so, where is it getting cut off - on insertion into the database or querying from the database?

either way, it's something to do with that ampersand character. what database are you using? i'm using mysql, and i don't think you have to do anything special to escape an ampersand. but i have seen before that oracle has a problem with it when storing an ampersand. it's somehow used to denote a variable, so what i've had to do with oracle is split it at the ampersand, doing something like:

update table set url = 'http://preview.traxsource.com/files/previews/nctgd038-3261--1-we_love_house--dave_floyd_&' || '_pook-p.mp3'
where id = 123...

not sure if that's what's going on but maybe it'll help.

and yeah, been seeing a lot of traffic yesterday! hope it'll keep up. 🙂

dave
</b>


Aaron
nml375 24 May, 2010
Hi Aaron,
Could you post a link to the form (here or in PM)?

Joomla only uses MySQL databases, same with ChronoForms. Further, ChronoForm uses various features within Joomla to make sure any and all queries are safe. Also, the only special function of & in MySQL, is that it may be used as a bitwize AND-operator. It will not, however, be interpreted as an operator within a string. As such, I doubt this is a database-related error.

/Fredrik
This topic is locked and no more replies can be posted.