Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-4841

URISupport: URI normalization duplicates query if path is empty

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.8.3
    • 2.7.5, 2.8.4, 2.10.0
    • camel-core
    • None
    • Novice

    Description

      URI with empty path, but non-empty query part is not properly normalized. The query part is in fact duplicated. E.g, URI "foobar://?foo=1&bar=2" is incorrectly normalized to "foobar://?foo=1&bar=2?bar=2&foo=1".

      This is caused by incorrect identification of the path part in org.apache.camel.util.URISupport.normalizeUri(String):
      int idx = path.indexOf('?');
      if (idx > 0)

      { path = path.substring(0, idx); }

      The comparison of "idx > 0" is incorrect, because this way, if '?' is the first character, the path is not set to empty string. The correct comparison should be "idx > -1" or "idx >= 0" or even just "idx != -1" since that's the only value that String.indexOf returns when the character is not found.

      Attachments

        Activity

          People

            njiang Willem Jiang
            koscejev Anton Koscejev
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: