Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Preventing HTML resolves of variables

Status
Not open for further replies.

cl8855

Programmer
Nov 28, 2000
47
US
Here's the issue. I have a web page storing fields into a database. Someone puts in something like server_name is "server%abc" as a field. I have several functions they can do on that field (like update) that passes them to "update_page.cfm?#server_name#"

Now when the #server_name# variable is resolved it is also resolving "%ab" in the middle of the variable name into some ascii character C or somethign like that.


So the general question is when I pass someone a link with a variable in it, how can I prevent the % sign from resolving? Or is there a way to escape it or what?

Same thing goes for all special characters probably, but especially the percent sign.

thanks.
 

Use the javascript "escape" function to encode the string before submitting it, and the equivalent "unescape" function the other end.

Hope this helps,
Dan
 
It's not HTML that's misinterpreting your input values. If you're using something like <input type="text" name="server_name"> for your input fields then whatever your users type in those fields will get passed "AS-IS". But, when passing that value as part of a link, HTML will try to interpret anything following the "%" sign as an HTML special character.

I'm not certain you can resolve this in HTML. You may have to resort to something like Javascript and try to "escape" the "%" value.

There's always a better way. The fun is trying to find it!
 
Beat me to the punch, Dan, good show!

There's always a better way. The fun is trying to find it!
 
OK I got the answer.

Turns out there is a function in coldfusion - URLEncodedFormat() which does exactly what I need, basically escapes any chars in the text automatically.

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top