Camel
  1. Camel
  2. CAMEL-4841

URISupport: URI normalization duplicates query if path is empty

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.8.3
    • Fix Version/s: 2.7.5, 2.8.4, 2.10.0
    • Component/s: camel-core
    • Labels:
      None
    • Estimated Complexity:
      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.

        Activity

        Hide
        Willem Jiang added a comment -

        Applied patch into trunk, camel-2.8.x, camel-2.7.x branch.

        Show
        Willem Jiang added a comment - Applied patch into trunk, camel-2.8.x, camel-2.7.x branch.

          People

          • Assignee:
            Willem Jiang
            Reporter:
            Anton Koscejev
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development