$g->setEncoding('utf-8');
$g;
};
- \($gen->generateString($$str))
+
+ # we assume $$str is valid UTF-8, but the SWIG binding doesn't
+ # know that, so ensure it's marked as UTF-8 even if it isnt...
+ my $out = $gen->generateString($$str);
+ utf8::decode($out);
+ \$out;
}
# SWIG instances aren't reference-counted, but $self is;
package PublicInbox::ViewVCS;
use strict;
use warnings;
-use Encode qw(find_encoding);
use PublicInbox::SolverGit;
use PublicInbox::WwwStream;
use PublicInbox::Linkify;
my %QP_MAP = ( A => 'oid_a', B => 'oid_b', a => 'path_a', b => 'path_b' );
my $max_size = 1024 * 1024; # TODO: configurable
-my $enc_utf8 = find_encoding('UTF-8');
my $BIN_DETECT = 8000; # same as git
sub html_page ($$$) {
return html_page($ctx, 200, \$log);
}
- $$blob = $enc_utf8->decode($$blob);
+ # TODO: detect + convert to ensure validity
+ utf8::decode($$blob);
my $nl = ($$blob =~ tr/\n/\n/);
my $pad = length($nl);
$l->linkify_1($$blob);
my $ok = $hl->do_hl($blob, $path) if $hl;
if ($ok) {
- $$ok = $enc_utf8->decode($$ok);
src_escape($$ok);
$blob = $ok;
} else {
{
my $ref = $hls->do_hl(\$str, 'foo.perl');
is(ref($ref), 'SCALAR', 'got a scalar reference back');
+ ok(utf8::valid($$ref), 'resulting string is utf8::valid');
like($$ref, qr/I can see you!/, 'we can see ourselves in output');
like($$ref, qr/&&/, 'escaped');