Skip to content

Fix parsing of already-decoded URIs #310

@zikolach

Description

@zikolach

I have issue with UriInterpolator attempting to decode part of URL which which is not originally encoded (just contains % character) or was already decoded.

Sample URL
https://storage.googleapis.com/realtyplusmag-news-photo/news-photo/108462.Welspun-Set-To-Acquire-70%-Debt-Of-Sintex-BAPL-2.jpg

Stack trace

URLDecoder: Illegal hex characters in escape (%) pattern - negative value
java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern - negative value
	at sttp.model.internal.Rfc3986$.decode(Rfc3986.scala:76)
	at sttp.model.UriInterpolator$UriBuilder$.sttp$model$UriInterpolator$UriBuilder$$decode(UriInterpolator.scala:665)
	at sttp.model.UriInterpolator$UriBuilder$.$anonfun$tokensToStringSeq$5(UriInterpolator.scala:620)
	at scala.collection.StrictOptimizedIterableOps.flatMap(StrictOptimizedIterableOps.scala:118)
	at scala.collection.StrictOptimizedIterableOps.flatMap$(StrictOptimizedIterableOps.scala:105)
	at scala.collection.immutable.Vector.flatMap(Vector.scala:113)
	at sttp.model.UriInterpolator$UriBuilder$.doToSeq$1(UriInterpolator.scala:618)
	at sttp.model.UriInterpolator$UriBuilder$.sttp$model$UriInterpolator$UriBuilder$$tokensToStringSeq(UriInterpolator.scala:632)
	at sttp.model.UriInterpolator$UriBuilder$Path$.pathFromTokens(UriInterpolator.scala:479)
	at sttp.model.UriInterpolator$UriBuilder$Path$.$anonfun$fromTokens$1(UriInterpolator.scala:475)
	at sttp.model.UriInterpolator$UriBuilder$.sttp$model$UriInterpolator$UriBuilder$$fromStartingToken(UriInterpolator.scala:565)
	at sttp.model.UriInterpolator$UriBuilder$Path$.fromTokens(UriInterpolator.scala:475)
	at sttp.model.UriInterpolator$.$anonfun$interpolate$1(UriInterpolator.scala:57)
	at scala.collection.LinearSeqOps.foldLeft(LinearSeq.scala:183)
	at scala.collection.LinearSeqOps.foldLeft$(LinearSeq.scala:179)
	at scala.collection.immutable.List.foldLeft(List.scala:79)
	at sttp.model.UriInterpolator$.interpolate(UriInterpolator.scala:56)
	at sttp.model.UriInterpolator$UriContext.uri(UriInterpolator.scala:36)

Originally posted by @zikolach in #257 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions