Changeset 4175


Ignore:
Timestamp:
2003-04-17T10:36:43+12:00 (21 years ago)
Author:
kjdon
Message:

changed the form searching stuff so that it doesn't use the escape function - this was causing trouble under windows for non latin characters. instead, have changed the format function to escape out any reserved characters (%, &, + etc) just in case these are entered in the box. haven't done all teh 'unsafe' characters, may need to do these too??

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/macros/query.dm

    r3775 r4175  
    321321\}
    322322
     323   //argfqv += escape(format(document.QueryForm.fqv[0].value));
    323324
    324325function updatefqv() \{
     
    326327   var i;
    327328   argfqv="";
    328    argfqv += escape(format(document.QueryForm.fqv[0].value));
     329   argfqv += format(document.QueryForm.fqv[0].value);
    329330   for (i=1; i<document.QueryForm.fqv.length;i++) \{
    330331       argfqv += ",";
    331        argfqv +=  escape(format(document.QueryForm.fqv[i].value));
     332       argfqv +=  format(document.QueryForm.fqv[i].value);
    332333   \}
    333334\}
     
    429430\}
    430431
     432//argq += escape(document.QueryForm.q.value);
     433
    431434function updateq() \{
    432435   argq = "";
    433    argq += escape(document.QueryForm.q.value);
     436   argq += format(document.QueryForm.q.value);
    434437\}
    435438
     
    440443
    441444// convert commas and spaces to plus
     445// also convert other illegal characters to %xx codes
    442446function format(string) \{
    443447   var str = "" + string;
    444448   var out = "", flag = 0;
     449   var ch = "";
    445450   var j;
    446451   for (j = 0; j < str.length; j++) \{
    447        if (str.charAt(j) == " "|| str.charAt(j) == ",") \{
    448        if ( flag == 0) \{
    449       out += "+";
    450       flag=1;
    451       \}
     452       ch=str.charAt(j);
     453       if (ch == " "|| ch == ",") \{
     454           if ( flag == 0) \{     
     455          out += "+";
     456          flag=1;
     457        \}
     458        continue;
    452459    \}
    453        else \{
    454           out += str.charAt(j);
    455       flag=0;
    456        \}
     460    if (ch == ";" || ch == ":" || ch == "/" || ch == "?" ||
     461            ch == "@" || ch == "&" || ch == "=" || ch == "#") \{
     462        out += escape(ch);
     463        flag=0;
     464        continue;
     465     \}       
     466    out += str.charAt(j);
     467    flag=0;
    457468   \}
    458469   return out;
Note: See TracChangeset for help on using the changeset viewer.