mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 08:18:55 +00:00
[#1163] fixed broken uri encoding when converting to emf uri
Signed-off-by: Christian Dietrich <christian.dietrich@itemis.de>
This commit is contained in:
parent
8be649bb02
commit
58a765b557
4 changed files with 28 additions and 24 deletions
|
@ -51,7 +51,7 @@ class UriExtensionsTest {
|
|||
@Test
|
||||
def void test_toUri03() {
|
||||
assertEquals(
|
||||
createURI('file://path with whitespaces/to/resource'),
|
||||
createURI('file://path%20with%20whitespaces/to/resource'),
|
||||
'file://path%20with%20whitespaces/to/resource'.toUri
|
||||
);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ class UriExtensionsTest {
|
|||
@Test
|
||||
def void test_toUri_04() {
|
||||
assertEquals(
|
||||
createURI('file:///path with whitespaces/to/resource'),
|
||||
createURI('file:///path%20with%20whitespaces/to/resource'),
|
||||
'file:///path%20with%20whitespaces/to/resource'.toUri
|
||||
);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ class UriExtensionsTest {
|
|||
@Test
|
||||
def void test_toUri_05() {
|
||||
assertEquals(
|
||||
createURI('file:///dir/\u0424\u0443 \u0411\u0430\u0440'),
|
||||
createURI('file:///dir/\u0424\u0443%20\u0411\u0430\u0440'),
|
||||
'file:///dir/%D0%A4%D1%83%20%D0%91%D0%B0%D1%80'.toUri
|
||||
);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ class UriExtensionsTest {
|
|||
@Test
|
||||
def void test_toUri_06() {
|
||||
assertEquals(
|
||||
createURI('file://dir/\u0424\u0443 \u0411\u0430\u0440'),
|
||||
createURI('file://dir/\u0424\u0443%20\u0411\u0430\u0440'),
|
||||
'file://dir/%D0%A4%D1%83%20%D0%91%D0%B0%D1%80'.toUri
|
||||
);
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ class UriExtensionsTest {
|
|||
@Test
|
||||
def void test_toUri_09() {
|
||||
assertEquals(
|
||||
createURI('something:/dir/\u0424\u0443 \u0411\u0430\u0440'),
|
||||
createURI('something:/dir/\u0424\u0443%20\u0411\u0430\u0440'),
|
||||
'something:/dir/%D0%A4%D1%83%20%D0%91%D0%B0%D1%80'.toUri
|
||||
);
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ class UriExtensionsTest {
|
|||
@Test
|
||||
def void test_toUri_10() {
|
||||
assertEquals(
|
||||
createURI('something://dir/\u0424\u0443 \u0411\u0430\u0440'),
|
||||
createURI('something://dir/\u0424\u0443%20\u0411\u0430\u0440'),
|
||||
'something://dir/%D0%A4%D1%83%20%D0%91%D0%B0%D1%80'.toUri
|
||||
);
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ class UriExtensionsTest {
|
|||
@Test
|
||||
def void test_toUri_11() {
|
||||
assertEquals(
|
||||
createURI('something:/path with whitespaces/to/resource'),
|
||||
createURI('something:/path%20with%20whitespaces/to/resource'),
|
||||
'something:/path%20with%20whitespaces/to/resource'.toUri
|
||||
);
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ class UriExtensionsTest {
|
|||
@Test
|
||||
def void test_toUri_12() {
|
||||
assertEquals(
|
||||
createURI('something://path with whitespaces/to/resource'),
|
||||
createURI('something://path%20with%20whitespaces/to/resource'),
|
||||
'something://path%20with%20whitespaces/to/resource'.toUri
|
||||
);
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ class UriExtensionsTest {
|
|||
@Test
|
||||
def void test_toUri_14() {
|
||||
assertEquals(
|
||||
createURI('file:///c:/Users/dietrich/\u0424\u0443 \u0411\u0430\u0440.mydsl'),
|
||||
createURI('file:///c:/Users/dietrich/\u0424\u0443%20\u0411\u0430\u0440.mydsl'),
|
||||
"file:///c%3A/Users/dietrich/%D0%A4%D1%83%20%D0%91%D0%B0%D1%80.mydsl".toUri
|
||||
);
|
||||
}
|
||||
|
@ -246,12 +246,14 @@ class UriExtensionsTest {
|
|||
|
||||
@Test
|
||||
def void testFilesWithSpaces() {
|
||||
assertEquals("file:///dir/Foo Bar.testlang", "file:///dir/Foo%20Bar.testlang".toUri.toUriString)
|
||||
val x = "file:///dir/Foo%20Bar.testlang".toUri
|
||||
val y = x.toUriString
|
||||
assertEquals("file:///dir/Foo%20Bar.testlang", y)
|
||||
}
|
||||
|
||||
@Test
|
||||
def void testFilesWithCyrillicSymbols() {
|
||||
assertEquals("file:///dir/\u0424\u0443 \u0411\u0430\u0440.testlang",
|
||||
assertEquals("file:///dir/\u0424\u0443%20\u0411\u0430\u0440.testlang",
|
||||
"file:///dir/%D0%A4%D1%83%20%D0%91%D0%B0%D1%80.testlang".toUri.toUriString)
|
||||
}
|
||||
|
||||
|
|
|
@ -50,28 +50,28 @@ public class UriExtensionsTest {
|
|||
@Test
|
||||
public void test_toUri03() {
|
||||
Assert.assertEquals(
|
||||
URI.createURI("file://path with whitespaces/to/resource"),
|
||||
URI.createURI("file://path%20with%20whitespaces/to/resource"),
|
||||
this._uriExtensions.toUri("file://path%20with%20whitespaces/to/resource"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_toUri_04() {
|
||||
Assert.assertEquals(
|
||||
URI.createURI("file:///path with whitespaces/to/resource"),
|
||||
URI.createURI("file:///path%20with%20whitespaces/to/resource"),
|
||||
this._uriExtensions.toUri("file:///path%20with%20whitespaces/to/resource"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_toUri_05() {
|
||||
Assert.assertEquals(
|
||||
URI.createURI("file:///dir/\u0424\u0443 \u0411\u0430\u0440"),
|
||||
URI.createURI("file:///dir/\u0424\u0443%20\u0411\u0430\u0440"),
|
||||
this._uriExtensions.toUri("file:///dir/%D0%A4%D1%83%20%D0%91%D0%B0%D1%80"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_toUri_06() {
|
||||
Assert.assertEquals(
|
||||
URI.createURI("file://dir/\u0424\u0443 \u0411\u0430\u0440"),
|
||||
URI.createURI("file://dir/\u0424\u0443%20\u0411\u0430\u0440"),
|
||||
this._uriExtensions.toUri("file://dir/%D0%A4%D1%83%20%D0%91%D0%B0%D1%80"));
|
||||
}
|
||||
|
||||
|
@ -92,28 +92,28 @@ public class UriExtensionsTest {
|
|||
@Test
|
||||
public void test_toUri_09() {
|
||||
Assert.assertEquals(
|
||||
URI.createURI("something:/dir/\u0424\u0443 \u0411\u0430\u0440"),
|
||||
URI.createURI("something:/dir/\u0424\u0443%20\u0411\u0430\u0440"),
|
||||
this._uriExtensions.toUri("something:/dir/%D0%A4%D1%83%20%D0%91%D0%B0%D1%80"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_toUri_10() {
|
||||
Assert.assertEquals(
|
||||
URI.createURI("something://dir/\u0424\u0443 \u0411\u0430\u0440"),
|
||||
URI.createURI("something://dir/\u0424\u0443%20\u0411\u0430\u0440"),
|
||||
this._uriExtensions.toUri("something://dir/%D0%A4%D1%83%20%D0%91%D0%B0%D1%80"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_toUri_11() {
|
||||
Assert.assertEquals(
|
||||
URI.createURI("something:/path with whitespaces/to/resource"),
|
||||
URI.createURI("something:/path%20with%20whitespaces/to/resource"),
|
||||
this._uriExtensions.toUri("something:/path%20with%20whitespaces/to/resource"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_toUri_12() {
|
||||
Assert.assertEquals(
|
||||
URI.createURI("something://path with whitespaces/to/resource"),
|
||||
URI.createURI("something://path%20with%20whitespaces/to/resource"),
|
||||
this._uriExtensions.toUri("something://path%20with%20whitespaces/to/resource"));
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ public class UriExtensionsTest {
|
|||
@Test
|
||||
public void test_toUri_14() {
|
||||
Assert.assertEquals(
|
||||
URI.createURI("file:///c:/Users/dietrich/\u0424\u0443 \u0411\u0430\u0440.mydsl"),
|
||||
URI.createURI("file:///c:/Users/dietrich/\u0424\u0443%20\u0411\u0430\u0440.mydsl"),
|
||||
this._uriExtensions.toUri("file:///c%3A/Users/dietrich/%D0%A4%D1%83%20%D0%91%D0%B0%D1%80.mydsl"));
|
||||
}
|
||||
|
||||
|
@ -225,12 +225,14 @@ public class UriExtensionsTest {
|
|||
|
||||
@Test
|
||||
public void testFilesWithSpaces() {
|
||||
Assert.assertEquals("file:///dir/Foo Bar.testlang", this._uriExtensions.toUriString(this._uriExtensions.toUri("file:///dir/Foo%20Bar.testlang")));
|
||||
final URI x = this._uriExtensions.toUri("file:///dir/Foo%20Bar.testlang");
|
||||
final String y = this._uriExtensions.toUriString(x);
|
||||
Assert.assertEquals("file:///dir/Foo%20Bar.testlang", y);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilesWithCyrillicSymbols() {
|
||||
Assert.assertEquals("file:///dir/\u0424\u0443 \u0411\u0430\u0440.testlang",
|
||||
Assert.assertEquals("file:///dir/\u0424\u0443%20\u0411\u0430\u0440.testlang",
|
||||
this._uriExtensions.toUriString(this._uriExtensions.toUri("file:///dir/%D0%A4%D1%83%20%D0%91%D0%B0%D1%80.testlang")));
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ class UriExtensions {
|
|||
*/
|
||||
def URI toEmfUri(java.net.URI netUri) {
|
||||
val decoded = netUri.toDecodedString
|
||||
val uri = URI.createURI(decoded);
|
||||
val uri = URI.createURI(decoded, false);
|
||||
val result = uri.withEmptyAuthority
|
||||
result
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class UriExtensions {
|
|||
URI _xblockexpression = null;
|
||||
{
|
||||
final String decoded = this.toDecodedString(netUri);
|
||||
final URI uri = URI.createURI(decoded);
|
||||
final URI uri = URI.createURI(decoded, false);
|
||||
final URI result = this.withEmptyAuthority(uri);
|
||||
_xblockexpression = result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue