Permalink
Browse files

VERSION 0.06

git-svn-id: http://svn.coderepos.org/share/lang/perl/URI-Escape-XS/trunk@35518 d0d07461-0603-4401-acd4-de1884942a52
  • Loading branch information...
1 parent aba1b36 commit 11d668a9b47c0c2b7af259bb67596273c9428254 dankogai committed Oct 7, 2009
Showing with 73 additions and 24 deletions.
  1. +13 −2 Changes
  2. +1 −0 MANIFEST
  3. +1 −1 README
  4. +18 −9 XS.xs
  5. +3 −3 lib/URI/Escape/XS.pm
  6. +1 −1 t/01-compat.t
  7. +15 −8 t/04-idn.t
  8. +21 −0 t/05-null.t
View
@@ -1,9 +1,20 @@
#
-# $Id: Changes,v 0.5 2009/03/24 14:24:09 dankogai Exp dankogai $
+# $Id: Changes,v 0.6 2009/10/07 11:40:30 dankogai Exp dankogai $
#
# Revision history for Revision history for URI-Escape-XS
#
-$Revision: 0.5 $ $Date: 2009/03/24 14:24:09 $
+$Revision: 0.6 $ $Date: 2009/10/07 11:40:30 $
++ t/05-null.t
+! XS.xs lib/URI/Escape/XS.pm
+ Addressed:
+ #45392: First invocation of encodeURIComponentIDN loses the path
+ #49375: decodeURIComponent() influences references from a regexp
+ #45855: Problems with undef
+ http://rt.cpan.org/Public/Bug/Display.html?id=45392
+ http://rt.cpan.org/Public/Bug/Display.html?id=49375
+ http://rt.cpan.org/Public/Bug/Display.html?id=45855
+
+0.05 2009/03/24 14:24:09
! lib/URI/Escape/XS.pm t/04-IDN.t
Now you can also use Net::LibIDN instead of Net::IDN::Encode
http://rt.cpan.org/Public/Bug/Display.html?id=44084
View
@@ -10,6 +10,7 @@ t/01-compat.t
t/02-basic.t
t/03-hashu.t
t/04-idn.t
+t/05-null.t
t/boilerplate.t
t/pod-coverage.t
t/pod.t
View
@@ -2,7 +2,7 @@ NAME
URI::Escape::XS - Drop-In replacement for URI::Escape
VERSION
- $Id: README,v 0.4 2009/03/24 14:24:09 dankogai Exp dankogai $
+ $Id: README,v 0.4 2009/03/24 14:24:09 dankogai Exp $
SYNOPSIS
# use it instead of URI::Escape
View
@@ -1,5 +1,5 @@
/*
- * $Id: XS.xs,v 0.3 2009/01/16 06:38:52 dankogai Exp $
+ * $Id: XS.xs,v 0.4 2009/10/07 11:40:30 dankogai Exp dankogai $
*/
#include "EXTERN.h"
@@ -35,12 +35,16 @@ static char escapes[256] =
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
};
-SV *encode_uri_component(SV *str){
- int slen = SvCUR(str);
- int dlen = 0;
- SV *result = newSV(slen * 3 + 1); /* at most 3 times */
+SV *encode_uri_component(SV *sstr){
+ SV *str, *result;
+ int slen, dlen;
U8 *src, *dst;
int i;
+ if (sstr == &PL_sv_undef) return newSV(0);
+ str = newSVsv(sstr); /* make a copy to make func($1) work */
+ slen = SvPOK(str) ? SvCUR(str) : 0;
+ dlen = 0;
+ result = newSV(slen * 3 + 1); /* at most 3 times */
SvPOK_on(result);
src = (U8 *)SvPV_nolen(str);
@@ -60,12 +64,17 @@ SV *encode_uri_component(SV *str){
return result;
}
-SV *decode_uri_component(SV *uri){
- int slen = SvCUR(uri);
- int dlen = 0;
- SV *result = newSV(slen + 1);
+SV *decode_uri_component(SV *suri){
+ SV *uri, *result;
+ int slen, dlen;
U8 buf[8], *dst, *src, *bp;
int i, hi, lo;
+ if (suri == &PL_sv_undef) return newSV(0);
+ /* if (!SvPOK(suri)) return newSV(0); */
+ uri = newSVsv(suri); /* make a copy to make func($1) work */
+ slen = SvPOK(uri) ? SvCUR(uri) : 0;
+ dlen = 0;
+ result = newSV(slen + 1);
SvPOK_on(result);
dst = (U8 *)SvPV_nolen(result);
@@ -1,11 +1,11 @@
package URI::Escape::XS;
#
-# $Id: XS.pm,v 0.5 2009/03/24 14:24:09 dankogai Exp dankogai $
+# $Id: XS.pm,v 0.6 2009/10/07 11:40:11 dankogai Exp $
#
use 5.008001;
use warnings;
use strict;
-our $VERSION = sprintf "%d.%02d", q$Revision: 0.5 $ =~ /(\d+)/g;
+our $VERSION = sprintf "%d.%02d", q$Revision: 0.6 $ =~ /(\d+)/g;
use base qw(Exporter);
our @EXPORT = qw(encodeURIComponent decodeURIComponent
@@ -118,7 +118,7 @@ URI::Escape::XS - Drop-In replacement for URI::Escape
=head1 VERSION
-$Id: XS.pm,v 0.5 2009/03/24 14:24:09 dankogai Exp dankogai $
+$Id: XS.pm,v 0.6 2009/10/07 11:40:11 dankogai Exp $
=cut
View
@@ -1,6 +1,6 @@
#!perl -w
#
-# $Id: 01-compat.t,v 0.2 2009/03/24 14:24:09 dankogai Exp dankogai $
+# $Id: 01-compat.t,v 0.2 2009/03/24 14:24:09 dankogai Exp $
#
# Original as URI-1.35/t/escape.t
#
View
@@ -1,26 +1,33 @@
#!perl -w
#
-# $Id: 04-idn.t,v 1.2 2009/03/24 14:24:09 dankogai Exp dankogai $
+# $Id: 04-idn.t,v 1.3 2009/10/07 11:40:30 dankogai Exp dankogai $
#
# Original as URI-1.35/t/escape.t
#
use URI::Escape::XS;
-use Test::More tests => 6;
+use Test::More tests => 8;
SKIP: {
use utf8;
eval { require Net::LibIDN }
or eval { require Net::IDN::Encode }
- or skip 'Net::LibIDN or Net::IDN::Encode required', 6;
- my $d = 'http://ドメイン名例.jp/dankogai/だん/ダン';
- my $e =
-'http:%2F%2Fxn--eckwd4c7cu47r2wf.jp%2Fdankogai%2F%E3%81%A0%E3%82%93%2F%E3%83%80%E3%83%B3';
+ or skip 'Net::LibIDN or Net::IDN::Encode required', 8;
+
+ my $d = 'http://cnn.com/news';
+ my $e = 'http:%2F%2Fcnn.com%2Fnews';
+ is encodeURIComponentIDN($d) => $e, 'first encodeURIComponentIDN must preserve the path';
+
+ $d = 'http://cnn.com/news';
+ $e = 'http:%2F%2Fcnn.com%2Fnews';
+ is encodeURIComponentIDN($d) => $e, 'second encodeURIComponentIDN must preserve the path as well';
+
+ $d = 'http://ドメイン名例.jp/dankogai/だん/ダン';
+ $e = 'http:%2F%2Fxn--eckwd4c7cu47r2wf.jp%2Fdankogai%2F%E3%81%A0%E3%82%93%2F%E3%83%80%E3%83%B3';
is decodeURIComponentIDN($e) => $d, 'decodeURIComponentIDN';
is encodeURIComponentIDN($d) => $e, 'encodeURIComponentIDN';
$d = 'http://ドメイン名例.JP:8080/dankogai/だん/ダン';
- $e =
-'http:%2F%2Fxn--eckwd4c7cu47r2wf.JP:8080%2Fdankogai%2F%E3%81%A0%E3%82%93%2F%E3%83%80%E3%83%B3';
+ $e = 'http:%2F%2Fxn--eckwd4c7cu47r2wf.JP:8080%2Fdankogai%2F%E3%81%A0%E3%82%93%2F%E3%83%80%E3%83%B3';
is decodeURIComponentIDN($e) => $d, 'decodeURIComponentIDN';
is encodeURIComponentIDN($d) => $e, 'encodeURIComponentIDN';
$d = 'http://مثال.إختبار';
View
@@ -0,0 +1,21 @@
+#!perl -w
+#
+# $Id: 05-null.t,v 1.1 2009/10/07 11:40:30 dankogai Exp dankogai $
+#
+# https://rt.cpan.org/Ticket/Display.html?id=45855
+
+use URI::Escape::XS;
+use Test::More tests => 6;
+
+{
+ no warnings 'uninitialized';
+ my $d;
+ is encodeURIComponent($d) => '', 'encodeURIComponent(null)';
+ is decodeURIComponent($d) => '', 'decodeURIComponent(null)';
+}
+
+$d = '';
+is length(encodeURIComponent($d)) => 0, 'length encodeURIComponent(\'\')';
+is defined(encodeURIComponent($d)) => 1, 'defined encodeURIComponent(\'\')';
+is length(decodeURIComponent($d)) => 0, 'length decodeURIComponent(\'\')';
+is defined(decodeURIComponent($d)) => 1, 'defined decodeURIComponent(\'\')';

0 comments on commit 11d668a

Please sign in to comment.