Skip to content

Commit

Permalink
Fix string octal escape encoding
Browse files Browse the repository at this point in the history
The bug affected invisible ASCII characters that have one of the two high bits set, so only DEL.
  • Loading branch information
laurmaedje committed Oct 17, 2023
1 parent 276bdc6 commit ea7fe33
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl BufExt for Vec<u8> {
}

self.push(octal(value >> 6));
self.push(octal((value >> 3) & 63));
self.push(octal((value >> 3) & 7));
self.push(octal(value & 7));
}
}
1 change: 1 addition & 0 deletions src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,7 @@ mod tests {
test_primitive!(Str(br"\n"), br"(\\n)");
test_primitive!(Str(b"a\x14b"), br"(a\024b)");
test_primitive!(Str(b"\xFF\xAA"), b"<FFAA>");
test_primitive!(Str(b"\x0A\x7F\x1F"), br"(\n\177\037)");

// Test text strings.
test_primitive!(TextStr("Hallo"), b"(Hallo)");
Expand Down

0 comments on commit ea7fe33

Please sign in to comment.