Changeset 22981
- Timestamp:
- 2010-09-28T15:45:30+13:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/macros/query.dm
r22948 r22981 604 604 function updateq() \{ 605 605 606 argq = ""; 607 argq += format(document.QueryForm.q.value); 606 argq = ""; 607 _If_("_cgiarga_" eq "sqlq",argq += format(document.QueryForm.q.value, 1);) 608 _If_("_cgiarga_" eq "q",argq += format(document.QueryForm.q.value);) 608 609 \} 609 610 … … 612 613 \} 613 614 614 615 615 // convert spaces to plus 616 // also convert other illegal characters (including commas)to %xx codes616 // also convert other illegal characters to %xx codes 617 617 // This routine used to treat commas like spaces (replacing them with a plus), 618 // but this is no longer good enough for handling sql-queries 619 function format(string) \{ 618 // but this is no longer good enough for handling sql-queries. 619 // Now if keepcommas == 1, URL encode commas, else (if undefined or 0), 620 // convert commas to plus. 621 function format(string, keepcommas) \{ 620 622 var str = "" + string; 621 623 var out = "", flag = 0; 622 624 var ch = ""; 623 625 var j; 624 for (j = 0; j < str.length; j++) \{ 626 for (j = 0; j < str.length; j++) \{ 625 627 ch=str.charAt(j); 628 629 if(ch == ",") \{ 630 if(keepcommas == 1) \{ 631 out += escape(ch); 632 flag=0; 633 continue; 634 \} 635 else \{ // can be undefined or maybe 0? 636 if (flag == 0) \{ 637 out += "+"; 638 flag=1; 639 \} 640 \} 641 continue; 642 \} 643 626 644 if (ch == " ") \{ 627 645 if (flag == 0) \{ … … 631 649 continue; 632 650 \} 633 if (ch == " ," || ch == ";" || ch == ":" || ch == "/" || ch == "?" ||651 if (ch == ";" || ch == ":" || ch == "/" || ch == "?" || 634 652 ch == "@" || ch == "&" || ch == "=" || ch == "#" || 635 653 ch == "%") \{
Note:
See TracChangeset
for help on using the changeset viewer.