Removed support for escaping a slash

This commit is contained in:
moandji.ezana 2015-01-22 16:02:32 +02:00
parent 9a8b85c6ea
commit 537c75757e
6 changed files with 46 additions and 4 deletions

View file

@ -61,7 +61,7 @@ class StringConverter implements ValueConverter {
if (ch == '\\' && next == '\\') {
i++;
} else if (ch == '\\' && !(next == 'b' || next == 'f' || next == 'n' || next == 't' || next == 'r' || next == '"' || next == '/' || next == '\\')) {
} else if (ch == '\\' && !(next == 'b' || next == 'f' || next == 'n' || next == 't' || next == 'r' || next == '"' || next == '\\')) {
return null;
}
}

View file

@ -156,7 +156,7 @@ public class BurntSushiValidTest {
@Test
public void string_escapes() throws Exception {
run("string-escapes");
run("string-escapes-modified");
}
@Test

View file

@ -69,7 +69,7 @@ public class StringTest {
public void should_support_special_characters_in_strings() {
Toml toml = new Toml().parse(new File(getClass().getResource("should_support_special_characters_in_strings.toml").getFile()));
assertEquals("\" \t \n \r \\ / \b \f", toml.getString("key"));
assertEquals("\" \t \n \r \\ \b \f", toml.getString("key"));
}
@Test
@ -85,6 +85,11 @@ public class StringTest {
new Toml().parse("key=\"\\m\"");
}
@Test(expected = IllegalStateException.class)
public void should_fail_on_escaped_slash() throws Exception {
new Toml().parse("key=\"\\/\"");
}
@Test(expected = IllegalStateException.class)
public void should_fail_on_text_after_literal_string() {
new Toml().parse("a = ' ' jdkf");

View file

@ -0,0 +1,30 @@
{
"backspace": {
"type": "string",
"value": "This string has a \u0008 backspace character."
},
"tab": {
"type": "string",
"value": "This string has a \u0009 tab character."
},
"newline": {
"type": "string",
"value": "This string has a \u000A new line character."
},
"formfeed": {
"type": "string",
"value": "This string has a \u000C form feed character."
},
"carriage": {
"type": "string",
"value": "This string has a \u000D carriage return character."
},
"quote": {
"type": "string",
"value": "This string has a \u0022 quote character."
},
"backslash": {
"type": "string",
"value": "This string has a \u005C backslash character."
}
}

View file

@ -0,0 +1,7 @@
backspace = "This string has a \b backspace character."
tab = "This string has a \t tab character."
newline = "This string has a \n new line character."
formfeed = "This string has a \f form feed character."
carriage = "This string has a \r carriage return character."
quote = "This string has a \" quote character."
backslash = "This string has a \\ backslash character."

View file

@ -1,3 +1,3 @@
key = "\" \t \n \r \\ \/ \b \f"
key = "\" \t \n \r \\ \b \f"
unicode_key = "more or less \u00B1"
unicode_key_uppercase = "more or less \U00B1"