mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
prepare to fix WEB-14454 — Browserify generates incorrect data uri. "charset:" used instead of "charset=" (see https://en.wikipedia.org/wiki/Data_URI_scheme).
This commit is contained in:
@@ -44,7 +44,7 @@ public class URLUtil {
|
||||
public static final String JAR_PROTOCOL = "jar";
|
||||
public static final String JAR_SEPARATOR = "!/";
|
||||
|
||||
public static final Pattern DATA_URI_PATTERN = Pattern.compile("data:([^,;]+/[^,;]+)(;charset=[^,;]+)?(;base64)?,(.+)");
|
||||
public static final Pattern DATA_URI_PATTERN = Pattern.compile("data:([^,;]+/[^,;]+)(;charset(?:=|:)[^,;]+)?(;base64)?,(.+)");
|
||||
|
||||
private URLUtil() { }
|
||||
|
||||
@@ -245,4 +245,5 @@ public class URLUtil {
|
||||
return host;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -23,12 +23,12 @@
|
||||
package com.intellij.util.io;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class UrlUtilTest {
|
||||
@Test
|
||||
@@ -72,4 +72,12 @@ public class UrlUtilTest {
|
||||
assertEquals("github.com", URLUtil.parseHostFromSshUrl(sshUrl));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDataUri() {
|
||||
byte[] test = "test".getBytes(CharsetToolkit.UTF8_CHARSET);
|
||||
assertThat(URLUtil.getBytesFromDataUri("data:text/plain;charset=utf-8;base64,dGVzdA=="), equalTo(test));
|
||||
// https://youtrack.jetbrains.com/issue/WEB-14581#comment=27-1014790
|
||||
assertThat(URLUtil.getBytesFromDataUri("data:text/plain;charset:utf-8;base64,dGVzdA=="), equalTo(test));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user