Skip Menu | will be shut down on March 1st, 2021.

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the CGI CPAN distribution.

Report information
The Basics
Id: 49690
Status: rejected
Priority: 0/
Queue: CGI

Owner: Nobody in particular
Requestors: vitalif [...]

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

Subject: utf8 support in CGI::cookie()
Download (untitled) / with headers
text/plain 3.4k
CGI::cookie() does not persist the utf8_on() flag of cookie names and values. This leads to different bugs, for example, Bugzilla bug tracker does not remember selected "Version" if its value is not latin1. A fixed implementation could look like... (see attach) ? ----------------------------------------------------------------- --- Flags: category=library severity=medium --- Site configuration information for perl 5.10.0: Configured by Debian Project at Sun Aug 16 22:37:28 UTC 2009. Summary of my perl5 (revision 5 version 10 subversion 0) configuration: Platform: osname=linux, osvers=2.6.26-2-amd64, archname=i486-linux-gnu-thread- multi uname='linux puccini 2.6.26-2-amd64 #1 smp fri aug 14 07:12:04 utc 2009 i686 gnulinux ' config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN - Dcccdlflags=-fPIC -Darchname=i486-linux-gnu -Dprefix=/usr -Dprivlib=/ usr/share/perl/5.10 -Darchlib=/usr/lib/perl/5.10 -Dvendorprefix=/usr - Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/ usr/local -Dsitelib=/usr/local/share/perl/5.10.0 -Dsitearch=/usr/local/ lib/perl/5.10.0 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/ man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/ man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs - Ud_csh -Ud_ualarm -Uusesfio -Uusenm -DDEBUGGING=-g -Doptimize=-O2 - Duseshrplib -Dd_dosuid -des' hint=recommended, useposix=true, d_sigaction=define useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=undef, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict- aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE - D_FILE_OFFSET_BITS=64', optimize='-O2 -g', cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing - pipe -I/usr/local/include' ccversion='', gccversion='4.3.4', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib /usr/lib64 libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt perllibs=-ldl -lm -lpthread -lc -lcrypt libc=/lib/, so=so, useshrplib=true, gnulibc_version='2.9' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -O2 -g -L/usr/local/lib' Locally applied patches: --- @INC for perl 5.10.0: /etc/perl /usr/local/lib/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl . --- Environment for perl 5.10.0: HOME=/home/vitali LANG=ru_RU.UTF-8 LANGUAGE= LD_LIBRARY_PATH=:/usr/lib/oracle/xe/app/oracle/product/10.2.0/ client/lib:/usr/lib/oracle/xe/app/oracle/product/10.2.0/client/lib LOGDIR (unset) PATH=/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/lib/oracle/xe/app/ oracle/product/10.2.0/client/bin:/usr/lib/oracle/xe/app/oracle/ product/10.2.0/client/bin PERL_BADLANG (unset) SHELL=/bin/bash
Subject: cgicookie.txt
Download cgicookie.txt
text/plain 1.7k
# cookie() with UTF-8 support... sub cookie { my($self,@p) = self_or_default(@_); my($name,$value,$path,$domain,$secure,$expires,$httponly) = rearrange(['NAME',['VALUE','VALUES'],'PATH','DOMAIN','SECURE','EXPIRES','HTTPONLY'],@p); require CGI::Cookie; require Encode; # if no value is supplied, then we retrieve the # value of the cookie, if any. For efficiency, we cache the parsed # cookies in our state variables. unless ( defined($value) ) { unless ($self->{'.cookies'}) { $self->{'.cookies'} = CGI::Cookie->fetch; if ($PARAM_UTF8) { my $v; my @a; for (keys %{$self->{'.cookies'}}) { $v = $self->{'.cookies'}->{$_}->value; Encode::_utf8_on($_); Encode::_utf8_on($v); push @a, $_, $v; } $self->{'.cookies'} = { @a }; } } # If no name is supplied, then retrieve the names of all our cookies. return () unless $self->{'.cookies'}; return keys %{$self->{'.cookies'}} unless $name; return () unless $self->{'.cookies'}->{$name}; return $self->{'.cookies'}->{$name} if defined($name) && $name ne ''; } # If we get here, we're creating a new cookie return undef unless defined($name) && $name ne ''; # this is an error my @param; push(@param,'-name'=>$name); push(@param,'-value'=>$value); push(@param,'-domain'=>$domain) if $domain; push(@param,'-path'=>$path) if $path; push(@param,'-expires'=>$expires) if $expires; push(@param,'-secure'=>$secure) if $secure; push(@param,'-httponly'=>$httponly) if $httponly; return new CGI::Cookie(@param); }
Download (untitled) / with headers
text/plain 134b
For this to move forward, it needs a peer review from someone else experienced with UTF-8. Automated tests would be helpful as well.
Download (untitled) / with headers
text/plain 240b
This issue has been copied to: please take all future correspondence there. This ticket will remain open but please do not reply here. This ticket will be closed when the github issue is dealt with.
Download (untitled) / with headers
text/plain 731b
Rejecting on the following grounds: 1) Age of the issue report (5 years) 2) Lack of any tests for the provided patch 3) As per RFC6265: cookie-name = token cookie-value = *cookie-octet / ( DQUOTE *cookie-octet DQUOTE ) cookie-octet = %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E ; US-ASCII characters excluding CTLs, ; whitespace DQUOTE, comma, semicolon, ; and backslash token = <token, defined in [RFC2616], Section 2.2> So a cookie shouldn't contain UTF8 characters anyway. If you can provide a fully tested patch for the latest version of the module i'm happy to apply it, otherwise i'm not going to spend any time on this.

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to