Skip to content

Commit

Permalink
added detection for server relative URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr4K4n authored and asolntsev committed Sep 16, 2023
1 parent 5249699 commit d62de1e
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1951,6 +1951,12 @@ private String getTokenValue(Token t, boolean literal) {
if (lastSlash != -1) {
uriResult = _URI.substring(0, lastSlash+1) + uriResult;
}
} else if (isServerRelativeURI(uriResult)) {
int uriOffset = _URI.indexOf("://") + 3;
int firstSlashAfterProtocol = _URI.substring(uriOffset).indexOf('/');
if (firstSlashAfterProtocol != -1) {
uriResult = _URI.substring(0, uriOffset + firstSlashAfterProtocol) + uriResult;
}
}

return uriResult;
Expand Down Expand Up @@ -1980,6 +1986,14 @@ private boolean isRelativeURI(String uri) {
}
}

private boolean isServerRelativeURI(String uri) {
try {
return uri.length() > 0 && uri.charAt(0) == '/' && !new URI(uri).isAbsolute();
} catch (URISyntaxException e) {
return false;
}
}

private int getCurrentLine() {
return _lexer.yyline();
}
Expand Down

0 comments on commit d62de1e

Please sign in to comment.