entity issues... &, >, <
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: entity issues... &, >, <

  1. #1
    supervillain gerbick's Avatar
    Join Date
    Jul 2000
    Location
    undecided.
    Posts
    18,967
    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 &amp;, &lt;, and &gt;.

    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 &amp;?

    ...yepo, need some help on this one...

  2. #2
    Junior Member
    Join Date
    Mar 2001
    Posts
    27

    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 = ['&#38;','&#60;','&#62;','&#34;']
    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
  •  




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com