Skip to content

Commit 46bec01

Browse files
committed
language-server: further improvement of URI to Path conversions to catch any remaining bad URIs that result in an exception (references #858)
Followup to commit fbe34a9
1 parent 536ab9b commit 46bec01

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

language-server/src/main/java/com/as3mxml/vscode/utils/LanguageServerCompilerUtils.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,16 @@ private static Optional<Path> getFilePath(URI uri) {
286286
|| uri.getAuthority() != null
287287
|| uri.getPort() != -1) {
288288
return Optional.empty();
289-
} else {
290-
return Optional.of(Paths.get(uri));
291289
}
290+
Path parsedPath = null;
291+
try {
292+
parsedPath = Paths.get(uri);
293+
} catch (Exception e) {
294+
// we explicitly detect several invalid parts of the URI above, but
295+
// there might be some that we missed, so better to be safe.
296+
return Optional.empty();
297+
}
298+
return Optional.of(parsedPath);
292299
}
293300

294301
public static CompletionItemKind getCompletionItemKindFromDefinition(IDefinition definition) {

0 commit comments

Comments
 (0)