Skip to content

Commit 3d15a6f

Browse files
committed
Remove deprecated INTL_IDNA_VARIANT_2003
Cf. <https://wiki.php.net/rfc/deprecate-and-remove-intl_idna_variant_2003>
1 parent e973663 commit 3d15a6f

File tree

4 files changed

+16
-110
lines changed

4 files changed

+16
-110
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ PHP NEWS
99
. Removed deprecated image2wbmp(). (cmb)
1010
. Removed deprecated png2wbmp() and jpeg2wbmp(). (cmb)
1111

12+
- Intl:
13+
. Removed deprecated INTL_IDNA_VARIANT_2003. (cmb)
14+
1215
<<< NOTE: Insert NEWS from last stable release here prior to actual release! >>>

UPGRADING

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ PHP 8.0 UPGRADE NOTES
2929
. The deprecated functions png2wbmp() and jpeg2wbmp() have been removed.
3030
RFC: https://wiki.php.net/rfc/deprecate-png-jpeg-2wbmp
3131

32+
- Intl:
33+
. The deprecated constant INTL_IDNA_VARIANT_2003 has been removed.
34+
RFC: https://wiki.php.net/rfc/deprecate-and-remove-intl_idna_variant_2003
35+
3236
========================================
3337
2. New Features
3438
========================================

ext/intl/idn/idn.c

Lines changed: 8 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
/* }}} */
3434

3535
enum {
36-
INTL_IDN_VARIANT_2003 = 0,
37-
INTL_IDN_VARIANT_UTS46
36+
INTL_IDN_VARIANT_UTS46 = 1
3837
};
3938

4039
/* {{{ grapheme_register_constants
@@ -73,7 +72,6 @@ void idn_register_constants( INIT_FUNC_ARGS )
7372
REGISTER_LONG_CONSTANT("IDNA_NONTRANSITIONAL_TO_UNICODE", UIDNA_NONTRANSITIONAL_TO_UNICODE, CONST_CS | CONST_PERSISTENT);
7473

7574
/* VARIANTS */
76-
REGISTER_LONG_CONSTANT("INTL_IDNA_VARIANT_2003", INTL_IDN_VARIANT_2003, CONST_CS | CONST_PERSISTENT);
7775
REGISTER_LONG_CONSTANT("INTL_IDNA_VARIANT_UTS46", INTL_IDN_VARIANT_UTS46, CONST_CS | CONST_PERSISTENT);
7876

7977
/* PINFO ERROR CODES */
@@ -176,85 +174,11 @@ static void php_intl_idn_to_46(INTERNAL_FUNCTION_PARAMETERS,
176174
uidna_close(uts46);
177175
}
178176

179-
static void php_intl_idn_to(INTERNAL_FUNCTION_PARAMETERS,
180-
const zend_string *domain, uint32_t option, int mode)
181-
{
182-
UChar* ustring = NULL;
183-
int ustring_len = 0;
184-
UErrorCode status;
185-
zend_string *u8str;
186-
187-
/* convert the string to UTF-16. */
188-
status = U_ZERO_ERROR;
189-
intl_convert_utf8_to_utf16(&ustring, &ustring_len, ZSTR_VAL(domain), ZSTR_LEN(domain), &status);
190-
191-
if (U_FAILURE(status)) {
192-
intl_error_set_code(NULL, status);
193-
194-
/* Set error messages. */
195-
intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 );
196-
if (ustring) {
197-
efree(ustring);
198-
}
199-
RETURN_FALSE;
200-
} else {
201-
UChar converted[MAXPATHLEN];
202-
int32_t converted_ret_len;
203-
204-
status = U_ZERO_ERROR;
205-
206-
#if U_ICU_VERSION_MAJOR_NUM >= 55
207-
UIDNAInfo info = UIDNA_INFO_INITIALIZER;
208-
UIDNA *idna = uidna_openUTS46((int32_t)option, &status);
209-
210-
if (U_FAILURE(status)) {
211-
intl_error_set( NULL, status, "idn_to_ascii: failed to create an UIDNA instance", 0 );
212-
RETURN_FALSE;
213-
}
214-
215-
if (mode == INTL_IDN_TO_ASCII) {
216-
converted_ret_len = uidna_nameToASCII(idna, ustring, ustring_len, converted, MAXPATHLEN, &info, &status);
217-
} else {
218-
converted_ret_len = uidna_nameToUnicode(idna, ustring, ustring_len, converted, MAXPATHLEN, &info, &status);
219-
}
220-
uidna_close(idna);
221-
#else
222-
UParseError parse_error;
223-
if (mode == INTL_IDN_TO_ASCII) {
224-
converted_ret_len = uidna_IDNToASCII(ustring, ustring_len, converted, MAXPATHLEN, (int32_t)option, &parse_error, &status);
225-
} else {
226-
converted_ret_len = uidna_IDNToUnicode(ustring, ustring_len, converted, MAXPATHLEN, (int32_t)option, &parse_error, &status);
227-
}
228-
#endif
229-
efree(ustring);
230-
231-
if (U_FAILURE(status)) {
232-
intl_error_set( NULL, status, "idn_to_ascii: cannot convert to ASCII", 0 );
233-
RETURN_FALSE;
234-
}
235-
236-
status = U_ZERO_ERROR;
237-
u8str = intl_convert_utf16_to_utf8(converted, converted_ret_len, &status);
238-
239-
if (!u8str) {
240-
/* Set global error code. */
241-
intl_error_set_code(NULL, status);
242-
243-
/* Set error messages. */
244-
intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8", 0 );
245-
RETURN_FALSE;
246-
}
247-
}
248-
249-
/* return the allocated string, not a duplicate */
250-
RETVAL_NEW_STR(u8str);
251-
}
252-
253177
static void php_intl_idn_handoff(INTERNAL_FUNCTION_PARAMETERS, int mode)
254178
{
255179
zend_string *domain;
256180
zend_long option = 0,
257-
variant = INTL_IDN_VARIANT_UTS46;
181+
variant = INTL_IDN_VARIANT_UTS46;
258182
zval *idna_info = NULL;
259183

260184
intl_error_reset(NULL);
@@ -265,9 +189,8 @@ static void php_intl_idn_handoff(INTERNAL_FUNCTION_PARAMETERS, int mode)
265189
RETURN_NULL(); /* don't set FALSE because that's not the way it was before... */
266190
}
267191

268-
if (variant != INTL_IDN_VARIANT_2003 && variant != INTL_IDN_VARIANT_UTS46) {
269-
php_intl_bad_args("invalid variant, must be one of {"
270-
"INTL_IDNA_VARIANT_2003, INTL_IDNA_VARIANT_UTS46}");
192+
if (variant != INTL_IDN_VARIANT_UTS46) {
193+
php_intl_bad_args("invalid variant, must be INTL_IDNA_VARIANT_UTS46");
271194
RETURN_FALSE;
272195
}
273196

@@ -281,29 +204,14 @@ static void php_intl_idn_handoff(INTERNAL_FUNCTION_PARAMETERS, int mode)
281204
}
282205
/* don't check options; it wasn't checked before */
283206

284-
if (variant == INTL_IDN_VARIANT_2003) {
285-
php_error_docref(NULL, E_DEPRECATED, "INTL_IDNA_VARIANT_2003 is deprecated");
286-
}
287-
288207
if (idna_info != NULL) {
289-
if (variant == INTL_IDN_VARIANT_2003) {
290-
php_error_docref0(NULL, E_NOTICE,
291-
"4 arguments were provided, but INTL_IDNA_VARIANT_2003 only "
292-
"takes 3 - extra argument ignored");
293-
} else {
294-
idna_info = zend_try_array_init(idna_info);
295-
if (!idna_info) {
296-
return;
297-
}
208+
idna_info = zend_try_array_init(idna_info);
209+
if (!idna_info) {
210+
return;
298211
}
299212
}
300213

301-
if (variant == INTL_IDN_VARIANT_2003) {
302-
php_intl_idn_to(INTERNAL_FUNCTION_PARAM_PASSTHRU, domain, (uint32_t)option, mode);
303-
}
304-
else {
305-
php_intl_idn_to_46(INTERNAL_FUNCTION_PARAM_PASSTHRU, domain, (uint32_t)option, mode, idna_info);
306-
}
214+
php_intl_idn_to_46(INTERNAL_FUNCTION_PARAM_PASSTHRU, domain, (uint32_t)option, mode, idna_info);
307215
}
308216

309217
/* {{{ proto string idn_to_ascii(string domain[, int options[, int variant[, array &idna_info]]])

ext/intl/tests/idn_uts46_errors.phpt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ var_dump(idn_to_ascii("", 0, INTL_IDNA_VARIANT_UTS46 + 10));
2121
echo "empty domain:", "\n";
2222
var_dump(idn_to_ascii("", 0, INTL_IDNA_VARIANT_UTS46));
2323

24-
echo "fourth arg for 2003 variant (only notice raised):", "\n";
25-
var_dump(idn_to_ascii("foo.com", 0, INTL_IDNA_VARIANT_2003, $foo));
26-
2724
echo "with error, but no details arg:", "\n";
2825
var_dump(idn_to_ascii("www.fußball.com-", 0, INTL_IDNA_VARIANT_UTS46));
2926

@@ -54,18 +51,12 @@ Warning: idn_to_ascii(): idn_to_ascii: bad arguments in %s on line %d
5451
NULL
5552
bad variant:
5653

57-
Warning: idn_to_ascii(): idn_to_ascii: invalid variant, must be one of {INTL_IDNA_VARIANT_2003, INTL_IDNA_VARIANT_UTS46} in %s on line %d
54+
Warning: idn_to_ascii(): idn_to_ascii: invalid variant, must be INTL_IDNA_VARIANT_UTS46 in %s on line %d
5855
bool(false)
5956
empty domain:
6057

6158
Warning: idn_to_ascii(): idn_to_ascii: empty domain name in %s on line %d
6259
bool(false)
63-
fourth arg for 2003 variant (only notice raised):
64-
65-
Deprecated: idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated in %s on line %d
66-
67-
Notice: idn_to_ascii(): 4 arguments were provided, but INTL_IDNA_VARIANT_2003 only takes 3 - extra argument ignored in %s on line %d
68-
string(7) "foo.com"
6960
with error, but no details arg:
7061
bool(false)
7162
with error, with details arg:

0 commit comments

Comments
 (0)