Files
perl-URI-Encode-XS/perl-URI-Encode-XS.spec
2025-08-12 18:18:22 +02:00

88 lines
2.9 KiB
RPMSpec

#
# spec file for package perl-URI-Encode-XS
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define cpan_name URI-Encode-XS
Name: perl-URI-Encode-XS
Version: 0.110.0
Release: 0
# 0.11 -> normalize -> 0.110.0
%define cpan_version 0.11
License: SUSE-Public-Domain
Summary: Perl URI encoder/decoder using C
URL: https://metacpan.org/release/%{cpan_name}
Source0: https://cpan.metacpan.org/authors/id/D/DF/DFARRELL/%{cpan_name}-%{cpan_version}.tar.gz
Source100: README.md
BuildRequires: perl
BuildRequires: perl-macros
Provides: perl(URI::Encode::XS) = %{version}
%undefine __perllib_provides
%{perl_requires}
%description
This is a Perl URI encoder/decoder written in XS based on at
https://tools.ietf.org/html/rfc3986. This module always encodes characters
that are not unreserved. When decoding, invalid escape sequences are
preserved, e.g:
uri_decode("foo%20bar%a/"); # foo bar%a/
uri_decode("foo%20bar%a"); # foo bar%a
uri_decode("foo%20bar%"); # foo bar%
As of version 0.10, the 'bench' script shows it to be significantly faster
than 'URI::Escape':
Rate escape encode_utf8 encode
escape 140114/s -- -94% -98%
encode_utf8 2255100/s 1509% -- -71%
encode 7735189/s 5421% 243% --
Rate unescape decode_utf8 decode
unescape 188714/s -- -95% -97%
decode_utf8 3744638/s 1884% -- -50%
decode 7429263/s 3837% 98% --
However this is just one string - the fewer encoded/decoded characters are
in the string, the closer the benchmark is likely to be (see 'bench' for
details of the benchmark). Different hardware will yield different results.
Another fast encoder/decoder which supports custom escape lists, is at
https://metacpan.org/pod/URI::XSEscape.
%prep
%autosetup -n %{cpan_name}-%{cpan_version}
find . -type f ! -path "*/t/*" ! -name "*.pl" ! -path "*/bin/*" ! -path "*/script/*" ! -path "*/scripts/*" ! -name "configure" -print0 | xargs -0 chmod 644
%build
perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="%{optflags}"
%make_build
%check
make test
%install
%perl_make_install
%perl_process_packlist
%perl_gen_filelist
%files -f %{name}.files
%doc bench
%license LICENSE
%changelog