Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-17255

ClientUtils.encodeLocalParamVal doesn't work with param refs, breaks SolrParams.toLocalParamsString

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • main (10.0), 9.7
    • SolrJ
    • None

    Description

      If you try to use SolrParams.toLocalParamsString where some of your param values are $other_param style param references, those refs will wind up wrapped in single quotes, preventing the param de-referencing from working.

      Example...

      final ModifiableSolrParams params = new ModifiableSolrParams();
      params.set("type", "edismax");
      params.set("v","$other_param");
      System.out.println(params.toLocalParamString())
      
      // Output: {! type=edismax v='$other_param'}
      

      Ironically: ClientUtils.encodeLocalParamVal actually has a check to see if the string starts with "$" which causes it to bypass a loop that checks to see if the string needs to be quoted – but bypassing that loop doesn't leave the method variables (i and len) in a state that allow the subsequent short-circut check (which returns the original value) to kick in – so the value is always falls through to the // We need to enclose in quotes... but now we need to escape logic

      (It looks like this bug has always existed in every version of these methods)

      Attachments

        1. SOLR-17255.patch
          5 kB
          Chris M. Hostetter

        Activity

          People

            hossman Chris M. Hostetter
            hossman Chris M. Hostetter
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: