Skip to content

Commit

Permalink
support more control characters
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 17, 2015
1 parent 782728f commit 2cca3e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Mojo/Util.pm
Expand Up @@ -301,7 +301,7 @@ sub tablify {

sub term_escape {
my $str = shift;
$str =~ s/([\x00-\x09\x0b-\x1f\x7f])/sprintf '\\x%02x', ord $1/ge;
$str =~ s/([\x00-\x09\x0b-\x1f\x7f\x80-\x9f])/sprintf '\\x%02x', ord $1/ge;
return $str;
}

Expand Down
3 changes: 2 additions & 1 deletion t/mojo/util.t
Expand Up @@ -457,6 +457,7 @@ is dumper([1, 2]), "[\n 1,\n 2\n]\n", 'right result';
# term_escape
is term_escape("Accept: */*\x0d\x0a"), "Accept: */*\\x0d\x0a", 'right result';
is term_escape("\t\b\r\n\f"), "\\x09\\x08\\x0d\n\\x0c", 'right result';
is term_escape("\x00\x09\x0b\x1f\x7f"), '\x00\x09\x0b\x1f\x7f', 'right result';
is term_escape("\x00\x09\x0b\x1f\x7f\x80\x9f"),
'\x00\x09\x0b\x1f\x7f\x80\x9f', 'right result';

done_testing();

0 comments on commit 2cca3e5

Please sign in to comment.