Skip Menu |

This queue is for tickets about the Template-Toolkit CPAN distribution.

Report information
The Basics
Id: 67431
Status: resolved
Priority: 0/
Queue: Template-Toolkit

People
Owner: Nobody in particular
Requestors: vfilippov [...] custis.ru
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Errors with UTF-8 filenames with UTF-8 flag on
Date: Wed, 13 Apr 2011 17:48:00 +0400
To: <bug-Template-Toolkit [...] rt.cpan.org>
From: Виталий Филиппов <vfilippov [...] custis.ru>
When you use UTF-8 template file names with non-ascii characters, TT sometimes fails with an error "file error - 1: not found". The reason is that Perl's %INC hash always clears the UTF-8 flag on its keys, so when Template::Provider::_load_compiled() does delete $INC{$file} with $file being a UTF-8 string with flag ON, the entry is not really removed from %INC, and "require()" returns 1. How to fix: add the line Encode::_utf8_off($file); before delete $INC{$file}; My system is Debian sid with Perl 5.10.1. How to reproduce: #!/usr/bin/perl use Template; use Encode; my $fn = 'test-тест.tt'; { open FD, '>', $fn; print FD "hello world\n"; close FD; } my $template = new Template({COMPILE_DIR => './', COMPILE_EXT => 'c'}); Encode::_utf8_off($fn); $template->process($fn, {}) || die $template->error; $template = new Template({COMPILE_DIR => './', COMPILE_EXT => 'c'}); $template->process($fn, {}) || die $template->error; Encode::_utf8_on($fn); $template->process($fn, {}) || die $template->error; __END__ Here, the last process() gives the error "file error - 1: not found". -- With best regards, VitaliyFilippov
Ticket migrated to github as https://github.com/abw/Template2/issues/105