15
15
#include < stdio.h>
16
16
#include < cmath>
17
17
18
- #if defined(NODE_HAVE_I18N_SUPPORT)
19
- #include < unicode/utf8.h>
20
- #include < unicode/utf.h>
21
- #endif
22
-
23
18
#define UNICODE_REPLACEMENT_CHARACTER 0xFFFD
24
19
25
20
namespace node {
@@ -113,21 +108,6 @@ namespace url {
113
108
output->assign (*buf, buf.length ());
114
109
return true ;
115
110
}
116
-
117
- // Unfortunately there's not really a better way to do this.
118
- // Iterate through each encoded codepoint and verify that
119
- // it is a valid unicode codepoint.
120
- static bool IsValidUTF8 (std::string* input) {
121
- const char * p = input->c_str ();
122
- int32_t len = input->length ();
123
- for (int32_t i = 0 ; i < len;) {
124
- UChar32 c;
125
- U8_NEXT_UNSAFE (p, i, c);
126
- if (!U_IS_UNICODE_CHAR (c))
127
- return false ;
128
- }
129
- return true ;
130
- }
131
111
#else
132
112
// Intentional non-ops if ICU is not present.
133
113
static bool ToUnicode (std::string* input, std::string* output) {
@@ -139,10 +119,6 @@ namespace url {
139
119
*output = *input;
140
120
return true ;
141
121
}
142
-
143
- static bool IsValidUTF8 (std::string* input) {
144
- return true ;
145
- }
146
122
#endif
147
123
148
124
// If a UTF-16 character is a low/trailing surrogate.
@@ -395,12 +371,6 @@ namespace url {
395
371
if (PercentDecode (input, length, &decoded) < 0 )
396
372
goto end;
397
373
398
- // If there are any invalid UTF8 byte sequences, we have to fail.
399
- // Unfortunately this means iterating through the string and checking
400
- // each decoded codepoint.
401
- if (!IsValidUTF8 (&decoded))
402
- goto end;
403
-
404
374
// Then we have to punycode toASCII
405
375
if (!ToASCII (&decoded, &decoded))
406
376
goto end;
0 commit comments