forked from package-url/packageurl-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The methods `uriEncode` and `uriDecode` did not properly handle percent-encoding. In particular, `uriEncode` didn't properly output two uppercase hex digits and `urlDecode` did not properly handle non-ASCII characters. Aditionally, if no percent-encoding was performed, these methods will now return the original string. Fixes package-url#150 Closes package-url#153 Fixes package-url#154
- Loading branch information
Showing
2 changed files
with
49 additions
and
29 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
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 |
---|---|---|
|
@@ -55,6 +55,19 @@ public static void setup() throws IOException { | |
json = new JSONArray(jsonTxt); | ||
} | ||
|
||
@Test | ||
public void testEncoding1() throws MalformedPackageURLException { | ||
PackageURL purl = new PackageURL("maven", "com.google.summit", "summit-ast", "2.2.0\n", null, null); | ||
Assert.assertEquals("pkg:maven/com.google.summit/[email protected]%0A", purl.toString()); | ||
} | ||
|
||
@Test | ||
public void testEncoding2() throws MalformedPackageURLException { | ||
PackageURL purl = new PackageURL("pkg:nuget/%D0%9Cicros%D0%BEft.%D0%95ntit%D1%83Fram%D0%B5work%D0%A1%D0%BEr%D0%B5"); | ||
Assert.assertEquals("Мicrosоft.ЕntitуFramеworkСоrе", purl.getName()); | ||
Assert.assertEquals("pkg:nuget/%D0%9Cicros%D0%BEft.%D0%95ntit%D1%83Fram%D0%B5work%D0%A1%D0%BEr%D0%B5", purl.toString()); | ||
} | ||
|
||
@Test | ||
public void testConstructorParsing() throws Exception { | ||
exception = ExpectedException.none(); | ||
|