Commit 4de79dd3 authored by Tim Rühsen's avatar Tim Rühsen 🍻

Punycode encode: Check input for valid unicode

parent d9050f6b
...@@ -68,6 +68,7 @@ ...@@ -68,6 +68,7 @@
#define punycode_success IDN2_OK #define punycode_success IDN2_OK
#define punycode_overflow IDN2_PUNYCODE_OVERFLOW #define punycode_overflow IDN2_PUNYCODE_OVERFLOW
#define punycode_big_output IDN2_PUNYCODE_BIG_OUTPUT #define punycode_big_output IDN2_PUNYCODE_BIG_OUTPUT
#define punycode_bad_input IDN2_PUNYCODE_BAD_INPUT
#define punycode_encode _idn2_punycode_encode #define punycode_encode _idn2_punycode_encode
/**********************************************************/ /**********************************************************/
...@@ -158,8 +159,8 @@ int punycode_encode( ...@@ -158,8 +159,8 @@ int punycode_encode(
if (max_out - out < 2) return punycode_big_output; if (max_out - out < 2) return punycode_big_output;
output[out++] = (char) input[j]; output[out++] = (char) input[j];
} }
/* else if (input[j] < n) return punycode_bad_input; */ else if (input[j] > 0x10FFFF || (input[j] >= 0xD800 && input[j] <= 0xDBFF))
/* (not needed for Punycode with unsigned code points) */ return punycode_bad_input;
} }
h = b = (punycode_uint) out; h = b = (punycode_uint) out;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment