Skip to content

Commit 9a4fbdd

Browse files
author
TheSnoozer
committed
#519: drop the '?', '@' and from the test-cases for 'reserved' characters - as per rfc2396 we can assume those chacters are escaped - if not there is still no harm done the remote-URL is simply not available as property
1 parent 62e5523 commit 9a4fbdd

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

core/src/main/java/pl/project13/core/GitDataProvider.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,31 @@ public static <T> SupplierEx<T> memoize(SupplierEx<T> delegate) {
281281
/**
282282
* If the git remote value is a URI and contains a user info component, strip the password from it if it exists.
283283
*
284+
* Note that this method will return an empty string if any failure occurred, while stripping the password from the
285+
* credentials. This merely serves as save-guard to avoid any potential password exposure inside generated properties.
286+
*
287+
* This method further operates on the assumption that a valid URL schema follows the rules outlined in
288+
* <a href=https://www.ietf.org/rfc/rfc2396.txt>RFC-2396</a> in section "3.2.2. Server-based Naming Authority"
289+
* which declares the following as valid URL schema:
290+
* <pre>
291+
* <userinfo>@<host>:<port>
292+
* </pre>
293+
* The "userinfo" part is declared in the same section allowing the following pattern:
294+
* <pre>
295+
* userinfo = *( unreserved | escaped | ";" | ":" | "&" | "=" | "+" | "$" | "," )
296+
* </pre>
297+
* The "unreserved" part is declared in section "2.3. Unreserved Characters" as the following:
298+
* <pre>
299+
* unreserved = alphanum | mark
300+
* mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"
301+
*
302+
* alphanum = alpha | digit
303+
* digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
304+
* alpha = lowalpha | upalpha
305+
* lowalpha = "a" | "b" | "c" | ... | "x" | "y" | "z"
306+
* upalpha = "A" | "B" | "C" | ... | "X" | "Y" | "Z"
307+
* </pre>
308+
*
284309
* @param gitRemoteString The value of the git remote
285310
* @return returns the gitRemoteUri with stripped password (might be used in http or https)
286311
* @throws GitCommitIdExecutionException Exception when URI is invalid

maven/src/test/java/pl/project13/core/UriUserInfoRemoverTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ public static Collection<Object[]> parameters() {
5252
{ "file:///path/to/repo.git/", "file:///path/to/repo.git/"},
5353
{ "file:///C:\\Users\\test\\example", "file:///C:\\Users\\test\\example"},
5454
{ "file://C:\\Users\\test\\example", "file://C:\\Users\\test\\example" },
55-
// use of 'reserved' characters as https://www.ietf.org/rfc/rfc2396.txt
56-
// note: left out '/' since we can't simply escape it
57-
{ "https://user:A;?:@&=+$,Z@example.com:8888", "https://user@example.com:8888" },
58-
// use of 'unreserved' characters as https://www.ietf.org/rfc/rfc2396.txt
55+
// Must Support: use of 'unreserved' characters as https://www.ietf.org/rfc/rfc2396.txt, Section "2.3. Unreserved Characters"
5956
{ "https://user:A-_.!~*'()Z@example.com:8888", "https://user@example.com:8888" },
60-
// use of 'delims' characters as https://www.ietf.org/rfc/rfc2396.txt
57+
// Optional Support: use of 'reserved' characters as https://www.ietf.org/rfc/rfc2396.txt, Section "2.2. Reserved Characters"
58+
// note: left out '/', '?', '@' since we technically expect user's need to escape those
59+
{ "https://user:A;:&=+$,Z@example.com:8888", "https://user@example.com:8888" },
60+
// Optional Support: use of 'delims' characters as https://www.ietf.org/rfc/rfc2396.txt, Section "2.4.3. Excluded US-ASCII Characters"
6161
{ "https://user:A<>#%\"Z@example.com:8888", "https://user@example.com:8888" },
62-
// use of 'unwise' characters as https://www.ietf.org/rfc/rfc2396.txt
62+
// Optional Support: use of 'unwise' characters as https://www.ietf.org/rfc/rfc2396.txt, Section "2.4.3. Excluded US-ASCII Characters"
6363
{ "https://user:A{}|\\^[]`Z@example.com:8888", "https://user@example.com:8888" },
6464
};
6565
return Arrays.asList(data);

0 commit comments

Comments
 (0)