-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for: Exception occurring when encoding the path containing unwise…
… characters (i.e space) (#364)
- Loading branch information
1 parent
2e958b7
commit dc05920
Showing
8 changed files
with
104 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
runtime/src/main/java/com/tietoevry/quarkus/resteasy/problem/InstanceUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.tietoevry.quarkus.resteasy.problem; | ||
|
||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.net.URLDecoder; | ||
import java.net.URLEncoder; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
public final class InstanceUtils { | ||
|
||
public static URI pathToInstance(String path) { | ||
if (path == null) { | ||
return null; | ||
} | ||
try { | ||
return new URI(encodeUnwiseCharacters(path)); | ||
} catch (URISyntaxException e) { | ||
return null; | ||
} | ||
} | ||
|
||
/** | ||
* @see <a href="https://www.ietf.org/rfc/rfc2396.txt">About unwise characters in RFC-2396</a> | ||
*/ | ||
private static String encodeUnwiseCharacters(String path) { | ||
return URLEncoder.encode(path, StandardCharsets.UTF_8); | ||
} | ||
|
||
public static String instanceToPath(URI instance) { | ||
return URLDecoder.decode(instance.toString(), StandardCharsets.UTF_8); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters