From aaa5113400f598bb42088f47ca3bb621c688d753 Mon Sep 17 00:00:00 2001 From: Shumaf Lovpache Date: Fri, 2 May 2025 14:03:32 +0300 Subject: [PATCH] [JavaScript Debugger] WEB-70462 Fix encoded file urls parsing (cherry picked from commit b8b0570b25c8019b9f19bb6c5f1230cae7c4d7c7) IJ-CR-157267 GitOrigin-RevId: e765d5660f343effc45c33696ff72169cc1c7166 --- .../backend/src/debugger/ScriptDebuggerUrls.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/platform/script-debugger/backend/src/debugger/ScriptDebuggerUrls.kt b/platform/script-debugger/backend/src/debugger/ScriptDebuggerUrls.kt index 7aae1021e3e7..785a9bda4ace 100644 --- a/platform/script-debugger/backend/src/debugger/ScriptDebuggerUrls.kt +++ b/platform/script-debugger/backend/src/debugger/ScriptDebuggerUrls.kt @@ -10,7 +10,6 @@ import com.intellij.util.Url import com.intellij.util.Urls import com.intellij.util.io.URLUtil import org.jetbrains.annotations.ApiStatus -import java.net.URISyntaxException @ApiStatus.Internal object ScriptDebuggerUrls { @@ -29,13 +28,16 @@ object ScriptDebuggerUrls { } private fun toUriPath(path: String): String { - var result = FileUtilRt.toSystemIndependentName(path) + var result = decodeAndConvertToSystemIndependent(path) if (result.length >= 2 && result[1] == ':') result = "/$result" return result } + // Shumaf: I hate that we have so many ways to parse a URL, yet none of them are correct + private fun decodeAndConvertToSystemIndependent(path: String): String = FileUtilRt.toSystemIndependentName(URLUtil.unescapePercentSequences(path)) + private fun toUri(absoluteOrRelativePath: String): Url { - var result = FileUtilRt.toSystemIndependentName(absoluteOrRelativePath) + var result = decodeAndConvertToSystemIndependent(absoluteOrRelativePath) if (result.length >= 2 && result[1] == ':') result = "/$result" return if (result.isNotEmpty() && result[0] == '/') newLocalFileUrl(result) else Urls.newUnparsable(result) }