of escaping bytea return value. Both cases did not handle backslash values properly.
-
+
PL/Perl - Perl Procedural Language
my $arg = shift;
- $arg =~ s!\\(\d{3})!chr(oct($1))!ge;
+ $arg =~ s!\\(?:\\|(\d{3}))!$1 ? chr(oct($1)) : "\\"!ge;
is how to escape binary data for a return value of type bytea>:
- $retval =~ s!([^ -~])!sprintf("\\%03o",ord($1))!ge;
+ $retval =~ s!(\\|[^ -~])!sprintf("\\%03o",ord($1))!ge;
return $retval;