-
supervillain
I have an *.asp page form that I parse out to XML. Problem is... people can put into the fields &, <, and >. Those need to be &, <, and >.
I was thinking of using a simple JavaScript that would validate and replace those values (I got a question for that in Scripting and Backend) but is there a way within the XML to allow those values within (CDATA) strings? Is there anyway to add a rule where those values, as long as they are within double-quotes - thus a string - it knows that & really equals &?
...yepo, need some help on this one...
-
escape tags
Hey,
I've had the same problem. I came up with this solution. It's a little messy with 2 functions but always works.
escape(<&tag>&<<>>>"No Problem");
function escape_str(str){
var munch = ['&','<','>','"'];
var repl = ['&','<','>','"']
var arrayLen = munch.length;
for(var i=0;i<arrayLen;i++){
str = escape_strSub1 (munch[i],repl[i],str);
}
return str;
}
function escape_strSub1(char,repl,str){
var clear;
var arr = str.split(char);
clear = arr.join(repl);
return clear;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|