From fd56aaba52278e749525f36fd3075648cf9b7532 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppi...@redhat.com>
Date: Fri, 28 Jul 2017 15:13:52 +0200
Subject: Fix handling elements starting with a non-ASCII character

---
 XML-XPath-1.39-Fix-non-ASCII-elements.patch | 90 +++++++++++++++++++++++++++++
 perl-XML-XPath.spec                         | 11 +++-
 2 files changed, 100 insertions(+), 1 deletion(-)
 create mode 100644 XML-XPath-1.39-Fix-non-ASCII-elements.patch

diff --git a/XML-XPath-1.39-Fix-non-ASCII-elements.patch 
b/XML-XPath-1.39-Fix-non-ASCII-elements.patch
new file mode 100644
index 0000000..ceea15b
--- /dev/null
+++ b/XML-XPath-1.39-Fix-non-ASCII-elements.patch
@@ -0,0 +1,90 @@
+From f7ae8e452235164c2950738ecb59854be534a978 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppi...@redhat.com>
+Date: Fri, 28 Jul 2017 15:08:49 +0200
+Subject: [PATCH] Fix non-ASCII elements
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Ported from 1.41:
+
+commit b9fe95de56c85c8a858492325d7e1834d9882655
+Author: Mohammad S Anwar <mohammad.an...@yahoo.com>
+Date:   Fri Jul 28 10:18:27 2017 +0100
+
+    - Fixed GitHub issue #4 (can't use non-ascii first character as element 
name). Thanks @nanis, @ikegami.
+
+Signed-off-by: Petr Písař <ppi...@redhat.com>
+---
+ MANIFEST                |  1 +
+ lib/XML/XPath/Parser.pm |  8 ++++++--
+ t/51elementname.t       | 26 ++++++++++++++++++++++++++
+ 3 files changed, 33 insertions(+), 2 deletions(-)
+ create mode 100644 t/51elementname.t
+
+diff --git a/MANIFEST b/MANIFEST
+index ab47ef9..8f1161b 100644
+--- a/MANIFEST
++++ b/MANIFEST
+@@ -79,6 +79,7 @@ t/47position.t
+ t/48translate.t
+ t/49literal.t
+ t/50xmlxpathparsercache.t
++t/51elementname.t
+ t/rdf.t
+ t/remove.t
+ t/insert.t
+diff --git a/lib/XML/XPath/Parser.pm b/lib/XML/XPath/Parser.pm
+index 75a44c6..cd2a8a1 100644
+--- a/lib/XML/XPath/Parser.pm
++++ b/lib/XML/XPath/Parser.pm
+@@ -42,8 +42,12 @@ use XML::XPath::NodeSet;
+         'self' => 'element',
+         );
+ 
+-$NCName = '([A-Za-z_][\w\\.\\-]*)';
+-$QName = "($NCName:)?$NCName";
++my $NameStartCharClassBody = 
"a-zA-Z_\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\x{2FF}\\x{370}-\\x{37D}\\x{37F}-\\x{1FFF}\\x{200C}-\\x{200D}\\x{2070}-\\x{218F}\\x{2C00}-\\x{2FEF}\\x{3001}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFFD}\\x{10000}-\\x{EFFFF}";
++my $NameCharClassBody = 
"${NameStartCharClassBody}\\-.0-9\\xB7\\x{300}-\\x{36F}\\x{203F}-\\x{2040}";
++my $Name = "(?:[$NameStartCharClassBody][$NameCharClassBody]*)";
++
++$NCName = $Name;
++$QName  = "$NCName(?::$NCName)?";
+ $NCWild = "${NCName}:\\*";
+ $QNWild = "\\*";
+ $NODE_TYPE = '((text|comment|processing-instruction|node)\\(\\))';
+diff --git a/t/51elementname.t b/t/51elementname.t
+new file mode 100644
+index 0000000..4461490
+--- /dev/null
++++ b/t/51elementname.t
+@@ -0,0 +1,26 @@
++#!/usr/bin/perl
++
++use utf8;
++use open qw(:std :encoding(utf-8));
++use Test::More tests => 3;
++use strict;
++use warnings;
++use XML::XPath;
++
++my $good_path = '/employees/employee[@age="30"]/yağcı';
++my $bad_path  = '/employees/employee[@age="30"]/şımarık';
++
++my $xp = XML::XPath->new(ioref => \*DATA);
++
++ok($xp);
++ok($xp->findvalue($good_path), 'değil');
++ok($xp->findvalue($bad_path), 'değil');
++
++__DATA__
++<?xml version="1.0" encoding="utf-8" ?>
++<employees>
++    <employee age="30">
++        <şımarık>değil</şımarık>
++        <yağcı>değil</yağcı>
++    </employee>
++</employees>
+-- 
+2.9.4
+
diff --git a/perl-XML-XPath.spec b/perl-XML-XPath.spec
index 47f777e..508674d 100644
--- a/perl-XML-XPath.spec
+++ b/perl-XML-XPath.spec
@@ -1,12 +1,15 @@
 Name:           perl-XML-XPath
 Version:        1.39
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        XPath parser and evaluator for Perl
 # XML/XPath.pm, XML/XPath/PerlSAX.pm, REAME: GPL+ or Artistic
 # Others: Artistic 2.0
 License:        Artistic 2.0 and (GPL+ or Artistic)
 URL:            http://search.cpan.org/dist/XML-XPath/
 Source0:        
http://www.cpan.org/authors/id/M/MA/MANWAR/XML-XPath-%{version}.tar.gz
+# Fix handling elements starting with a non-ASCII character, in upstream 1.41,
+# <https://github.com/manwar/XML-XPath/issues/4>
+Patch0:         XML-XPath-1.39-Fix-non-ASCII-elements.patch
 
 BuildArch:      noarch
 BuildRequires:  coreutils
@@ -28,9 +31,11 @@ BuildRequires:  perl(vars)
 BuildRequires:  perl(XML::Parser) >= 2.23
 # Tests
 BuildRequires:  perl(lib)
+BuildRequires:  perl(open)
 BuildRequires:  perl(Path::Tiny) >= 0.076
 BuildRequires:  perl(Test)
 BuildRequires:  perl(Test::More)
+BuildRequires:  perl(utf8)
 # Optional tests
 BuildRequires:  perl(CPAN::Meta)
 BuildRequires:  perl(Test::CPAN::Meta)
@@ -51,6 +56,7 @@ this as they support functionality beyond XPath.
 
 %prep
 %setup -q -n XML-XPath-%{version}
+%patch0 -p1
 
 %build
 perl Makefile.PL INSTALLDIRS=vendor NO_PACKLIST=1
@@ -77,6 +83,9 @@ make test
 %{_mandir}/man3/*.3*
 
 %changelog
+* Fri Jul 28 2017 Petr Pisar <ppi...@redhat.com> - 1.39-2
+- Fix handling elements starting with a non-ASCII character
+
 * Wed Nov 09 2016 Jitka Plesnikova <jples...@redhat.com> - 1.39-1
 - 1.39 bump
 
-- 
cgit v1.1


        
https://src.fedoraproject.org/cgit/perl-XML-XPath.git/commit/?h=f24&id=fd56aaba52278e749525f36fd3075648cf9b7532
_______________________________________________
perl-devel mailing list -- perl-devel@lists.fedoraproject.org
To unsubscribe send an email to perl-devel-le...@lists.fedoraproject.org

Reply via email to