Skip to content

Commit a2389f8

Browse files
committed
Build correct URL for content security policy (#1837)
It seems that the JDK in 2025.2 works differently when parsing URLs
1 parent 3b62a44 commit a2389f8

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

CHANGELOG.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This document provides a high-level view of the changes introduced by release.
1111

1212
- Prevent "Read access not allowed" when using LLMs (#1822)
1313
- Prevent "InvalidVirtualFileAccessException" when iterating the file tree (#1825)
14+
- Build correct URL for content security policy in IntelliJ 2025.2 EAP (#1837)
1415

1516
=== 0.44.5
1617

src/main/java/org/asciidoc/intellij/editor/javafx/PreviewStaticServer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,16 @@ public static String createCSP(@NotNull Map<String, String> attributes) {
7676
highlightjs = " http://localhost:" + BuiltInServerManager.getInstance().getPort() + PREFIX;
7777
}
7878
}
79-
result = "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' " + Urls.parseEncoded("http://localhost:" + BuiltInServerManager.getInstance().getPort() + PREFIX + "/scripts/").toExternalForm() + highlightjs + "; "
80-
+ "style-src 'unsafe-inline' https: http: " + Urls.parseEncoded("http://localhost:" + BuiltInServerManager.getInstance().getPort() + PREFIX + "/styles/").toExternalForm() + "; "
79+
result = "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' " + Urls.parseEncoded("http://localhost:" + BuiltInServerManager.getInstance().getPort() + PREFIX + "scripts/").toExternalForm() + highlightjs + "; "
80+
+ "style-src 'unsafe-inline' https: http: " + Urls.parseEncoded("http://localhost:" + BuiltInServerManager.getInstance().getPort() + PREFIX + "styles/").toExternalForm() + "; "
8181
+ "img-src file: data: localfile: *; connect-src 'none'; font-src *; " +
8282
"object-src data: file: localfile: *;" + // used for interactive SVGs
8383
"media-src 'none'; child-src 'none'; " +
8484
"frame-src 'self' https://player.vimeo.com/ https://www.youtube.com/ https://structurizr.com/"; // used for vimeo/youtube iframes
8585
} else {
8686
// this will restrict external content as much as possible
87-
result = "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' " + Urls.parseEncoded("http://localhost:" + BuiltInServerManager.getInstance().getPort() + PREFIX + "/scripts/").toExternalForm() + "; "
88-
+ "style-src 'unsafe-inline' " + Urls.parseEncoded("http://localhost:" + BuiltInServerManager.getInstance().getPort() + PREFIX + "/styles/").toExternalForm() + "; "
87+
result = "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' " + Urls.parseEncoded("http://localhost:" + BuiltInServerManager.getInstance().getPort() + PREFIX + "scripts/").toExternalForm() + "; "
88+
+ "style-src 'unsafe-inline' " + Urls.parseEncoded("http://localhost:" + BuiltInServerManager.getInstance().getPort() + PREFIX + "styles/").toExternalForm() + "; "
8989
+ "img-src file: data: localfile: ; connect-src 'none'; " +
9090
"font-src " + Urls.parseEncoded("http://localhost:" + BuiltInServerManager.getInstance().getPort() + PREFIX + "/").toExternalForm() + "; " +
9191
"object-src data: file: localfile: ;" + // used for interactive SVGs
@@ -289,7 +289,7 @@ private static BrowserPanel getBrowserPanel() {
289289

290290
public static String signFile(String file) {
291291
String md5 = BrowserPanel.calculateMd5(file, null);
292-
return Urls.parseEncoded("http://localhost:" + BuiltInServerManager.getInstance().getPort() + PREFIX + "/image?file=" + getBrowserPanel().signFile(file) + "&amp;hash=" + md5).toExternalForm();
292+
return Urls.parseEncoded("http://localhost:" + BuiltInServerManager.getInstance().getPort() + PREFIX + "image?file=" + getBrowserPanel().signFile(file) + "&amp;hash=" + md5).toExternalForm();
293293
}
294294

295295
private void sendDocument(FullHttpRequest request, @NotNull VirtualFile file, @NotNull Project project, @NotNull Channel channel) {

0 commit comments

Comments
 (0)