libidn2/libidn2-2.0.4-std3-ascii-rules.patch

108 lines
3.9 KiB
Diff
Raw Blame History

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 */
+ /* _<><5F><EFBFBD> */
+ {"_\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
From f09a3c4657838e63751f9cd0c6c2b4f7485b68e9 Mon Sep 17 00:00:00 2001
From: Tim Rühsen <tim.ruehsen@gmx.de>
Date: Sun, 18 Feb 2018 18:38:25 +0100
Subject: [PATCH] Fix idn2 --nostd3asciirules to --usestd3asciirules
---
src/idn2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/idn2.c b/src/idn2.c
index a3e19c0..4a13a82 100644
--- a/src/idn2.c
+++ b/src/idn2.c
@@ -92,7 +92,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
--no-tr46 Disable TR46 processing\n\
"), stdout);
fputs (_("\
- --nostd3asciirules Disable STD3 ASCII rules\n\
+ --usestd3asciirules Enable STD3 ASCII rules\n\
--debug Print debugging information\n\
--quiet Silent operation\n\
"), stdout);
--
libgit2 0.26.0