aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/syntax
diff options
context:
space:
mode:
authorGravatar laurentlb <laurentlb@google.com>2017-06-26 17:28:28 +0200
committerGravatar Marcel Hlopko <hlopko@google.com>2017-06-26 18:43:43 +0200
commit3759d00356e7bf1dcf42e34cb83ad7bf3153a9c2 (patch)
treea7e0769e2ab92616914a0881f3c238f26da2a170 /src/test/java/com/google/devtools/build/lib/syntax
parenta7be6f6df4d3cc5f0f8107b8ffc15f0496e001c6 (diff)
Forbid octal sequences greater than \377 (0xff) in strings.
RELNOTES[INC]: In strings, octal sequences greater than \377 are now forbidden (e.g. "\\600"). Previously, Blaze had the same behavior as Python 2, where "\\450" == "\050". PiperOrigin-RevId: 160147169
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/syntax')
-rw-r--r--src/test/java/com/google/devtools/build/lib/syntax/LexerTest.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/LexerTest.java b/src/test/java/com/google/devtools/build/lib/syntax/LexerTest.java
index ce768b22d8..0fd91df959 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/LexerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/LexerTest.java
@@ -303,13 +303,20 @@ public class LexerTest {
@Test
public void testOctalEscapes() throws Exception {
// Regression test for a bug.
- assertThat(values(tokens("'\\0 \\1 \\11 \\77 \\111 \\1111 \\377 \\777 \\776'")))
- .isEqualTo("STRING(\0 \1 \t \u003f I I1 \u00ff \u00ff \u00fe) NEWLINE EOF");
+ assertThat(values(tokens("'\\0 \\1 \\11 \\77 \\111 \\1111 \\377'")))
+ .isEqualTo("STRING(\0 \1 \t \u003f I I1 \u00ff) NEWLINE EOF");
// Test boundaries (non-octal char, EOF).
assertThat(values(tokens("'\\1b \\1'"))).isEqualTo("STRING(\1b \1) NEWLINE EOF");
}
@Test
+ public void testOctalEscapeOutOfRange() throws Exception {
+ assertThat(values(tokens("'\\777'"))).isEqualTo("STRING(\u00ff) NEWLINE EOF");
+ assertThat(lastError.toString())
+ .isEqualTo("/some/path.txt:1: octal escape sequence out of range (maximum is \\377)");
+ }
+
+ @Test
public void testTripleQuotedStrings() throws Exception {
assertThat(values(tokens("\"\"\"a\"b'c \n d\"\"e\"\"\"")))
.isEqualTo("STRING(a\"b'c \n d\"\"e) NEWLINE EOF");