Changeset 1594 for MDService2


Ignore:
Timestamp:
10/24/11 20:53:12 (13 years ago)
Author:
gaba
Message:

escape querystring

Location:
MDService2/branches/MDService_simple3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • MDService2/branches/MDService_simple3/WebContent/scripts/mdservice_model.js

    r1588 r1594  
    437437        var params = "?";
    438438        if (this.query != null) {
    439                 escaped_sq = escape(this.query);
    440                 //escaped_sq =escape(this.query).replace(/%20/g,"%2520").replace(/\%2[27]/g,"%2522") ;
    441                 //escaped_sq = escaped_sq.replace(/%7C/g,"%257C").replace(/\+/g,"%2B");
    442                 //params = params + "query=" + escape(this.query) + "&";
    443                 params = params + "query=" + escaped_sq + "&";
     439                params = params + "query=" + escapequerystring(this.query) + "&";
    444440        }
    445441        /*
  • MDService2/branches/MDService_simple3/WebContent/scripts/mdservice_searchclause.js

    r1584 r1594  
    4242                this.relation = "=";
    4343        }
     44       
     45        this.is_complex = true;
    4446}
    4547
     
    317319                        return "ISOCAT( " + this.category + ") " + this.relation + " " + this.value;
    318320        }
    319         return this.index.replace(" ","_") + " " + this.relation + " " + this.value;
     321        return this.index.trim().replace(" ","_") + " " + this.relation + " " + this.value;
     322};
     323
     324/** special handling for special characters: double escaping (escape the %-sign)
     325 * to survive the %-encoding through the request (and parsing) down to the transformation in XCQL2XPath.xsl
     326 * it's: whitespace, and single and double-quotes (unified to double quotes %22)
     327*/
     328SearchClause.prototype.escape = function(){
     329        var escape_string = "";
     330        var escape_value_string = "";
     331       
     332        escape_value_string =escape(this.value).replace(/%20/g,"%2520").replace(/\%2[27]/g,"%2522").replace(/%7C/g,"%257C").replace(/\+/g,"%2B");
     333
     334        if (this.is_complex) {
     335                escape_string = escape_string + escape(this.index.trim().replace(" ","_") + " " + this.relation + " ") + escape_value_string;
     336        } else {
     337                // case more simple words in search
     338                escape_string = escape_value_string;
     339        }       
     340        return escape_string;
     341       
     342};
     343
     344SearchClause.createFromData = function(scstr){
     345        var n;
     346        var scarr;
     347        var rel = "";
     348        n = scstr.indexOf("=");
     349        if (n > 0){
     350                scarr = scstr.split("=");
     351                rel = "=";
     352        }
     353        n = scstr.indexOf(" any ");
     354        if (n > 0){
     355                scarr = scstr.split(" any ");
     356                rel = "any";
     357        }
     358        n = scstr.indexOf(" contains ");
     359        if (n > 0){
     360                scarr = scstr.split(" contains ");
     361                rel = "contains";
     362        }
     363        n = scstr.indexOf("<");
     364        if (n > 0){
     365                scarr = scstr.split("<");
     366                rel = "<";
     367        }
     368        n = scstr.indexOf(">");
     369        if (n > 0){
     370                scarr = scstr.split(">");
     371                rel = ">";
     372        }
     373        n = scstr.indexOf(" all ");
     374        if (n > 0){
     375                scarr = scstr.split(" all ");
     376                rel = "all";
     377        }
     378        //notifyUser("scarr:" + scarr[0] + scarr[1],'debug');
     379       
     380        if (scarr == undefined) {
     381                //this.issimpletext = true;
     382                sc = new SearchClause('*','any',scstr);
     383                sc.is_complex = false;
     384        } else {
     385                //this.issimpletext = false;
     386                sc = new SearchClause(scarr[0],rel,scarr[1]);
     387                sc.is_complex = true;
     388        }
     389
     390        return sc;
    320391};
    321392/*
     
    516587                        if (i > 0) {screl = "and";}
    517588                        for( var j=0;j<arr_or.length;j++){
    518                                 var scstr = $.trim(arr_or[j]);
     589                                if (j > 0) {screl = "or";}
    519590                               
    520                                 // parse rel
    521                                 //notifyUser("j:"+scstr,'debug');
    522                                 var n;
    523                                 var scarr;
    524                                 var rel = "";
    525                                 n = scstr.indexOf("=");
    526                                 if (n > 0){
    527                                         scarr = scstr.split("=");
    528                                         rel = "=";
    529                                 }
    530                                 n = scstr.indexOf(" any ");
    531                                 if (n > 0){
    532                                         scarr = scstr.split(" any ");
    533                                         rel = "any";
    534                                 }
    535                                 n = scstr.indexOf(" contains ");
    536                                 if (n > 0){
    537                                         scarr = scstr.split(" contains ");
    538                                         rel = "contains";
    539                                 }
    540                                 n = scstr.indexOf("<");
    541                                 if (n > 0){
    542                                         scarr = scstr.split("<");
    543                                         rel = "<";
    544                                 }
    545                                 n = scstr.indexOf(">");
    546                                 if (n > 0){
    547                                         scarr = scstr.split(">");
    548                                         rel = ">";
    549                                 }
    550                                 n = scstr.indexOf(" all ");
    551                                 if (n > 0){
    552                                         scarr = scstr.split(" all ");
    553                                         rel = "all";
    554                                 }
    555                                 //var simplecalusetext = scstr.split("");
    556                                 if (j > 0) {screl = "or";}
    557                                 //notifyUser("scarr:" + scarr[0] + scarr[1],'debug');
    558                                
    559                                 if (scarr == undefined) {
    560                                         sc = new SearchClause('*','any',scstr);//sc = new SearchClause('','','');
    561                                 } else {
    562                                         sc = new SearchClause(scarr[0],rel,scarr[1]);
    563                                 }
    564 
    565                                 this.addsearchclause(sc,screl,i,j);
    566                                 //searchclauseset.addsearchclause(sc,screl,i,j);
     591                                sc = SearchClause.createFromData($.trim(arr_or[j]));
     592                                this.addsearchclause(sc,screl,i,j);                             
    567593                        }
    568594                }
    569595        },
     596       
    570597       
    571598        buildsctext: function(){
     
    596623                }       
    597624                if ((i == 1 && j == 1) && (this.sctext.substring(0,6) == '* any ')) {
    598                         this.sctext  = sctext.replace('* any ','');
     625                        this.sctext  = this.sctext.replace('* any ','');
    599626                }
    600627                if (uncompletequery){
     
    643670};
    644671
     672function escapequerystring(querystring){
     673        var arr = Query.simplequerystring(querystring);
     674        var sc, screl;
     675        var escape_string = "";
     676        var add_bracket = false;
     677       
     678        //notifyUser(arr,'debug');
     679        var arr_and = arr.split(" and ");
     680        screl = "";
     681        for( var i=0;i<arr_and.length;i++){
     682                var scstring = $.trim(arr_and[i]);
     683               
     684                add_bracket = false;
     685                if (scstring.substring(0,1) == "(" && scstring.substring(scstring.length-1) == ")") {
     686                        scstring = scstring.substring(1,scstring.length-1);
     687                        scstring = $.trim(scstring);
     688                        escape_string = escape_string + "(";
     689                        add_bracket = true;
     690                }
     691               
     692                //notifyUser("i:" + scstring,'debug');
     693                var arr_or = scstring.split(" or ");
     694                if (i > 0) {screl = "and";}
     695               
     696                for( var j=0;j<arr_or.length;j++){
     697                        var scstr = $.trim(arr_or[j]);         
     698                        if (j > 0) {screl = "or";}
     699                       
     700                        sc = SearchClause.createFromData(scstr);
     701                        if (screl != ""){
     702                                escape_string  = escape_string + "%20" + screl + "%20";
     703                        }
     704                        escape_string = escape_string + sc.escape();
     705                }
     706                if (add_bracket){
     707                        escape_string = escape_string + ")";
     708                }
     709        }
     710        return escape_string;
     711}
     712
  • MDService2/branches/MDService_simple3/WebContent/scripts/mdservice_ui_load.js

    r1588 r1594  
    2424function loadTooltiptable() {
    2525         
    26          var uri = window.location.pathname + "static/info.xml";
     26         var uri = window.location.pathname + "/../../static/info.xml";
    2727         
    2828         $.get(uri,function(data, textStatus){
  • MDService2/branches/MDService_simple3/src/xsl/html_snippets.xsl

    r1574 r1594  
    123123                                        </td>
    124124                                        <td valign="top">
    125                                                 <label>Complex query</label><span id="switch-input" name='detail_index' class='cmd'></span><br/>
     125                                                <label>Complex query</label><span id="switch-input" class='cmd'></span><br/>
    126126                                                <!--  <div id="searchclauselist"></div>-->                                                     
    127127                                                <!--<input type="checkbox" checked="false" id="input-withsummary" name="WS"/><label>with Summary</label>
Note: See TracChangeset for help on using the changeset viewer.