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

Improve URL decoding (followup of SOLR-4265)

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.0
    • Fix Version/s: 4.1, 6.0
    • Component/s: None
    • Labels:
      None

      Description

      Followup of SOLR-4265:
      SOLR-4265 has 2 problems:

      • it reads the whole InputStream into a String and this one can be big. This wastes memory, especially when your query string from the POSted form data is near the 2 Megabyte limit. The String is then packed in splitted form into a big Map.
      • it does not report corrupt UTF-8

      The attached patch will do 2 things:

      • The decoding of the POSTed form data is done on the ServletInputStream, directly parsing the bytes (not chars). Key/Value pairs are extracted and %-decoded to byte[] on the fly. URL-parameters from getQueryString() are parsed with the same code using ByteArrayInputStream on the original String, interpreted as UTF-8 (this is a hack, because Servlet API does not give back the original bytes from the HTTP request). To be standards conform, the query String should be interpreted as US-ASCII, but with this approach, not full escaped UTF-8 from the HTTP request survive.
      • the byte[] key/value pairs are converted to Strings using CharsetDecoder

      This will be memory efficient and will report incorrect escaped form data, so people will no longer complain if searches hit no results or similar.

        Attachments

        1. index.jsp
          0.3 kB
          Dawid Weiss
        2. request.http
          0.4 kB
          Dawid Weiss
        3. SOLR-4283.patch
          17 kB
          Uwe Schindler
        4. SOLR-4283.patch
          16 kB
          Uwe Schindler
        5. SOLR-4283.patch
          15 kB
          Uwe Schindler
        6. SOLR-4283.patch
          13 kB
          Uwe Schindler
        7. SOLR-4283.patch
          11 kB
          Uwe Schindler

          Issue Links

            Activity

              People

              • Assignee:
                thetaphi Uwe Schindler
                Reporter:
                thetaphi Uwe Schindler
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: