Front page | perl.perl5.porters |
Postings from September 2010
[perl #77654] quotemeta() fails to quote literal non-word character under utf8
Thread Previous
|
Thread Next
From:
Mitchell N Charity
Date:
September 3, 2010 01:57
Subject:
[perl #77654] quotemeta() fails to quote literal non-word character under utf8
Message ID:
rt-3.6.HEAD-5116-1283457496-373.77654-75-0@perl.org
# New Ticket Created by Mitchell N Charity
# Please include the string: [perl #77654]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=77654 >
This is a bug report for perl from mncharity@vendian.org,
generated with the help of perlbug 1.39 running under perl 5.12.1.
-----------------------------------------------------------------
[Please describe your issue here]
quotemeta() fails to quote a CENT SIGN when,
using utf8, the string is created with
a literal CENT SIGN character, instead of with \xA2 .
----
use utf8;
use Test;
plan( tests => 21 );
# Bug Synopsis
# quotemeta() fails to quote a CENT SIGN when,
# using utf8, the string is created with
# a literal CENT SIGN character, instead of with \xA2 .
ok("¢","\xA2"); # ok
ok(quotemeta("\xA2"),"\\¢"); # ok
ok(quotemeta("¢"),"\\¢"); # NOT OK
ok(quotemeta("¢"),quotemeta("\xA2")); # NOT OK
# Bug Demonstration
my $a = "¢";
my $b = "\xA2";
ok($a,$b);
ok(($a eq $b),1);
ok(quotemeta($a),quotemeta($b)); # NOT OK
my $quoted = "\\\xA2";
ok("\\".$a,$quoted);
ok("\\".$b,$quoted);
ok(quotemeta($a),$quoted); # NOT OK
ok(quotemeta($b),$quoted); # ok
# Additional notes
# CENT SIGN is \xA2
ok("¢","\xA2");
# CENT SIGN is not a word character
ok("a"=~/\w/,1);
ok("a"=~/\W/,"");
ok("¢"=~/\p{IsWord}/,"");
ok("¢"=~/\P{IsWord}/,1);
ok("¢"=~/\w/,"");
ok("¢"=~/\W/,1);
# Regexps behave correctly
my $s;
$s = "¢"; $s =~ s/([^A-Za-z_0-9])/\\$1/g;
ok($s,$quoted);
$s = "¢"; $s =~ s/(\P{IsWord})/\\$1/g;
ok($s,$quoted);
$s = "¢"; $s =~ s/(\W)/\\$1/g;
ok($s,$quoted);
----
1..21
# Running under perl version 5.012001 for linux
# Current time local: Thu Sep 2 15:42:28 2010
# Current time GMT: Thu Sep 2 19:42:28 2010
# Using Test.pm version 1.25_02
ok 1
ok 2
not ok 3
# Test 3 got: "\xA2" (./bug.pl at line 14)
# Expected: "\\\xA2"
# ./bug.pl line 14 is: ok(quotemeta("¢"),"\\¢"); # NOT OK
not ok 4
# Test 4 got: "\xA2" (./bug.pl at line 15)
# Expected: "\\\xA2"
# ./bug.pl line 15 is: ok(quotemeta("¢"),quotemeta("\xA2")); # NOT OK
ok 5
ok 6
not ok 7
# Test 7 got: "\xA2" (./bug.pl at line 24)
# Expected: "\\\xA2"
# ./bug.pl line 24 is: ok(quotemeta($a),quotemeta($b)); # NOT OK
ok 8
ok 9
not ok 10
# Test 10 got: "\xA2" (./bug.pl at line 28)
# Expected: "\\\xA2"
# ./bug.pl line 28 is: ok(quotemeta($a),$quoted); # NOT OK
ok 11
ok 12
ok 13
ok 14
ok 15
ok 16
ok 17
ok 18
ok 19
ok 20
ok 21
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=core
severity=medium
---
Site configuration information for perl 5.12.1:
Configured by mncharity at Sun Jul 4 18:40:05 EDT 2010.
Summary of my perl5 (revision 5 version 12 subversion 1) configuration:
Platform:
osname=linux, osvers=2.6.32-22-generic, archname=x86_64-linux
uname='linux pencil 2.6.32-22-generic #36-ubuntu smp thu jun 3
19:31:57 utc 2010 x86_64 gnulinux '
config_args='-des -Dprefix=/usr/local/perl512'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include'
ccversion='', gccversion='4.4.3', gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64
libs=-lnsl -ldl -lm -lcrypt -lutil -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.11.1.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.11.1'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib
-fstack-protector'
Locally applied patches:
---
@INC for perl 5.12.1:
/usr/local/perl512/lib/site_perl/5.12.1/x86_64-linux
/usr/local/perl512/lib/site_perl/5.12.1
/usr/local/perl512/lib/5.12.1/x86_64-linux
/usr/local/perl512/lib/5.12.1
.
---
Environment for perl 5.12.1:
HOME=/home/mncharity
LANG=en_US.utf8
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
PERL_BADLANG (unset)
SHELL=/bin/bash
Thread Previous
|
Thread Next