363: Don't emit octal escape for null character followed by digit r=kdy1 a=erikdesjardins

Fixes #361

Co-authored-by: Erik Desjardins <erikdesjardins@users.noreply.github.com>
This commit is contained in:
bors[bot] 2019-04-10 06:09:13 +00:00
commit 31a2af103d
2 changed files with 24 additions and 0 deletions

View File

@ -358,6 +358,16 @@ impl<'a> Emitter<'a> {
.replace("\r", "\\r")
.replace("\t", "\\t")
.replace('\u{000B}', "\\v")
.replace("\00", "\\x000")
.replace("\01", "\\x001")
.replace("\02", "\\x002")
.replace("\03", "\\x003")
.replace("\04", "\\x004")
.replace("\05", "\\x005")
.replace("\06", "\\x006")
.replace("\07", "\\x007")
.replace("\08", "\\x008")
.replace("\09", "\\x009")
.replace("\0", "\\0");
// let value = node.value.replace("\n", "\\n");

View File

@ -158,6 +158,20 @@ a;",
);
}
#[test]
fn no_octal_escape() {
test_from_to(
r#"'\x00a';
'\x000';
'\x001';
'\x009'"#,
r#"'\0a';
'\x000';
'\x001';
'\x009';"#,
);
}
#[derive(Debug, Clone)]
struct Buf(Arc<RwLock<Vec<u8>>>);
impl Write for Buf {