Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-17630

UriComponentsBuilder.toUriString() is broken

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 5.0.8, 5.1.1
    • Fix Version/s: 5.0.12, 5.1.4
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      UriComponentsBuilder.toUriString() (and possibly UriComponentsBuilder.encode()) is broken as of 5.0.8.

      The code was changed from 

      return build(false).encode().toUriString();

       to

      return encode().build().toUriString();

      without any change to the javadoc.

      There are 2 problems with this (other than the javadoc issue)

      1. UriComponentsBuilder itself gets mutated by calling toUriString(), which is unexpected behavior.
      2. If you have a query param value with curly braces such as "{{{{", an IllegalStateException will now be thrown. If you have a closing brace such as "{{{}", no exception will be thrown but it won't be url-encoded, either.

      On top of that, the javadoc for UriComponentsBuilder.encode() basically says it will give the expected result while UriComponents.encode() will not, but not encoding braces and throwing IllegalStateExceptions is obviously not the expected result. It seems the variable expansion mechanism introduced is affecting behavior even when this feature is not used.

       

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rstoya05-aop Rossen Stoyanchev
                Reporter:
                rougou rougou
                Last updater:
                Spring Issuemaster
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  47 weeks, 1 day ago