From c877ff92a9fb0f23ca0227a9f73b8cb019806069 Mon Sep 17 00:00:00 2001 From: dakkar Date: Thu, 10 Sep 2009 15:42:17 +0200 Subject: add "encode-uri" EXSLT function --- lib/XML/LibXSLT/EXSLT.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/XML/LibXSLT/EXSLT.pm b/lib/XML/LibXSLT/EXSLT.pm index fce93e9..9bf375f 100644 --- a/lib/XML/LibXSLT/EXSLT.pm +++ b/lib/XML/LibXSLT/EXSLT.pm @@ -2,11 +2,14 @@ package XML::LibXSLT::EXSLT; use strict; use warnings; use XML::LibXML; +use URI::Escape; +use Encode; my $STRING_NS='http://exslt.org/strings'; my @funcs=( [$STRING_NS,'split',\&estr_split], + [$STRING_NS,'encode-uri',\&estr_uri_escape], ); sub apply_to { @@ -41,4 +44,17 @@ sub estr_split { return $doc; } +sub estr_uri_escape { + my ($string,$unsafe_mode,$encoding)=@_; + + $encoding||='utf8'; + + my $unsafe=q{^a-zA-Z0-9\-_.!~*'()}; #'; + if (!$unsafe_mode) { + $unsafe.=q{;/?:@&=+$,\[\]}; + } + + return uri_escape(encode($encoding,$string),$unsafe); +} + 1; -- cgit v1.2.3