Added upstream patch to fix STD3 ASCII rules (#1543021)

This commit is contained in:
Robert Scheck 2018-02-18 15:11:38 +01:00
parent c046c4b5c2
commit 0f60f51f7a
2 changed files with 91 additions and 1 deletions

View File

@ -0,0 +1,82 @@
From 31b11be35dd841dc1a97c45321b22c3376b01031 Mon Sep 17 00:00:00 2001
From: Tim Rühsen <tim.ruehsen@gmx.de>
Date: Thu, 8 Feb 2018 12:52:06 +0100
Subject: [PATCH] Fix STD3 ASCII rules
---
lib/idna.c | 15 ++++++++++++++-
lib/lookup.c | 5 ++++-
tests/test-lookup.c | 9 ++++++++-
3 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/lib/idna.c b/lib/idna.c
index 5434492..c961332 100644
--- a/lib/idna.c
+++ b/lib/idna.c
@@ -180,7 +180,20 @@ _idn2_label_test (int what, const uint32_t * label, size_t llen)
size_t i;
for (i = 0; i < llen; i++)
if (_idn2_disallowed_p (label[i]))
- return IDN2_DISALLOWED;
+ {
+ if ((what & (TEST_TRANSITIONAL | TEST_NONTRANSITIONAL)) &&
+ (what & TEST_ALLOW_STD3_DISALLOWED))
+ {
+ IDNAMap map;
+ get_idna_map (label[i], &map);
+ if (map_is (&map, TR46_FLG_DISALLOWED_STD3_VALID) ||
+ map_is (&map, TR46_FLG_DISALLOWED_STD3_MAPPED))
+ continue;
+
+ }
+
+ return IDN2_DISALLOWED;
+ }
}
if (what & TEST_CONTEXTJ)
diff --git a/lib/lookup.c b/lib/lookup.c
index 10b004f..9094aeb 100644
--- a/lib/lookup.c
+++ b/lib/lookup.c
@@ -89,7 +89,10 @@ label (const uint8_t * src, size_t srclen, uint8_t * dst, size_t * dstlen,
TEST_DISALLOWED |
TEST_CONTEXTJ_RULE |
TEST_CONTEXTO_WITH_RULE |
- TEST_UNASSIGNED | TEST_BIDI, p, plen);
+ TEST_UNASSIGNED | TEST_BIDI |
+ ((flags & IDN2_NONTRANSITIONAL) ? TEST_NONTRANSITIONAL : 0) |
+ ((flags & IDN2_USE_STD3_ASCII_RULES) ? 0 : TEST_ALLOW_STD3_DISALLOWED),
+ p, plen);
if (rc != IDN2_OK)
{
diff --git a/tests/test-lookup.c b/tests/test-lookup.c
index 03d8396..fb23427 100644
--- a/tests/test-lookup.c
+++ b/tests/test-lookup.c
@@ -814,13 +814,20 @@ static const struct idna idna[] = {
},
/* √.com */
{"\xe2\x88\x9a.com", "xn--19g.com", IDN2_OK, IDN2_TRANSITIONAL},
- /* domains with non-STD3 characters (removed by default when using TR46 transitional/non-trnasitional */
+ /* domains with non-STD3 characters (removed by default when using TR46 transitional/non-transitional */
{"_443._tcp.example.com", "_443._tcp.example.com", IDN2_OK, 0},
{"_443._tcp.example.com", "_443._tcp.example.com", IDN2_OK, IDN2_TRANSITIONAL},
{"_443._tcp.example.com", "_443._tcp.example.com", IDN2_OK, IDN2_NONTRANSITIONAL},
{"_443._tcp.example.com", "443.tcp.example.com", IDN2_OK, IDN2_USE_STD3_ASCII_RULES|IDN2_NONTRANSITIONAL},
{"_443._tcp.example.com", "443.tcp.example.com", IDN2_OK, IDN2_USE_STD3_ASCII_RULES|IDN2_TRANSITIONAL},
{"_443._tcp.example.com", "_443._tcp.example.com", IDN2_OK, IDN2_USE_STD3_ASCII_RULES}, /* flag is ignored when not using TR46 */
+ /* _üˆš */
+ {"_\xc3\xbc", "xn--_-eha", IDN2_DISALLOWED, 0},
+ {"_\xc3\xbc", "xn--_-eha", IDN2_OK, IDN2_TRANSITIONAL},
+ {"_\xc3\xbc", "xn--_-eha", IDN2_OK, IDN2_NONTRANSITIONAL},
+ {"_\xc3\xbc", "xn--tda", IDN2_OK, IDN2_USE_STD3_ASCII_RULES|IDN2_NONTRANSITIONAL},
+ {"_\xc3\xbc", "xn--tda", IDN2_OK, IDN2_USE_STD3_ASCII_RULES|IDN2_TRANSITIONAL},
+ {"_\xc3\xbc", "xn--_-eha", IDN2_DISALLOWED, IDN2_USE_STD3_ASCII_RULES}, /* flag is ignored when not using TR46 */
};
static int ok = 0, failed = 0;
--
libgit2 0.26.0

View File

@ -1,13 +1,14 @@
Summary: Library to support IDNA2008 internationalized domain names Summary: Library to support IDNA2008 internationalized domain names
Name: libidn2 Name: libidn2
Version: 2.0.4 Version: 2.0.4
Release: 2%{?dist} Release: 3%{?dist}
License: (GPLv2+ or LGPLv3+) and GPLv3+ License: (GPLv2+ or LGPLv3+) and GPLv3+
Group: System Environment/Libraries Group: System Environment/Libraries
URL: https://www.gnu.org/software/libidn/#libidn2 URL: https://www.gnu.org/software/libidn/#libidn2
Source0: https://ftp.gnu.org/gnu/libidn/%{name}-%{version}.tar.gz Source0: https://ftp.gnu.org/gnu/libidn/%{name}-%{version}.tar.gz
Source1: https://ftp.gnu.org/gnu/libidn/%{name}-%{version}.tar.gz.sig Source1: https://ftp.gnu.org/gnu/libidn/%{name}-%{version}.tar.gz.sig
Patch0: libidn2-2.0.0-rpath.patch Patch0: libidn2-2.0.0-rpath.patch
Patch1: libidn2-2.0.4-std3-ascii-rules.patch
BuildRequires: libunistring-devel BuildRequires: libunistring-devel
Requires(post): /sbin/install-info, /sbin/ldconfig Requires(post): /sbin/install-info, /sbin/ldconfig
Requires(preun): /sbin/install-info Requires(preun): /sbin/install-info
@ -33,6 +34,10 @@ developing applications that use libidn2.
%patch0 -p1 -b .rpath %patch0 -p1 -b .rpath
touch -c -r configure.rpath configure touch -c -r configure.rpath configure
touch -c -r m4/libtool.m4.rpath m4/libtool.m4 touch -c -r m4/libtool.m4.rpath m4/libtool.m4
%patch1 -p1 -b .std3-ascii-rules
touch -c -r lib/idna.c.std3-ascii-rules lib/idna.c
touch -c -r lib/lookup.c.std3-ascii-rules lib/lookup.c
touch -c -r tests/test-lookup.c.std3-ascii-rules tests/test-lookup.c
%build %build
%configure --disable-static %configure --disable-static
@ -86,6 +91,9 @@ fi
%{_datadir}/gtk-doc/ %{_datadir}/gtk-doc/
%changelog %changelog
* Sun Feb 18 2018 Robert Scheck <robert@fedoraproject.org> 2.0.4-3
- Added upstream patch to fix STD3 ASCII rules (#1543021)
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.4-2 * Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild