Skip to content

Commit 3cb7d1b

Browse files
committed
Remove custom UTF-8 check function from ext/libxml
This was originally introduced as a workaround for a libxml2 bug [1]. This bug has been fixed for more than a decade [2], and we can use the libxml2 API again. We bumped our version requirement for libxml2 beyond that in 7.4 [3]. [1] 7e53511 [2] GNOME/libxml2@3ffe90e [3] 74235ca Closes GH-18706.
1 parent 56abb31 commit 3cb7d1b

File tree

4 files changed

+2
-28
lines changed

4 files changed

+2
-28
lines changed

UPGRADING.INTERNALS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ PHP 8.5 INTERNALS UPGRADE NOTES
6262

6363
- ext/libxml
6464
. The refcount APIs now return an `unsigned int` instead of an `int`.
65+
. Removed php_libxml_xmlCheckUTF8(). Use xmlCheckUTF8() from libxml instead.
6566

6667
- ext/pdo
6768
. Added `php_pdo_stmt_valid_db_obj_handle()` to check if the database object

ext/libxml/libxml.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,32 +1236,6 @@ PHP_FUNCTION(libxml_get_external_entity_loader)
12361236
/* }}} */
12371237

12381238
/* {{{ Common functions shared by extensions */
1239-
bool php_libxml_xmlCheckUTF8(const unsigned char *s)
1240-
{
1241-
size_t i;
1242-
unsigned char c;
1243-
1244-
for (i = 0; (c = s[i++]);) {
1245-
if ((c & 0x80) == 0) {
1246-
} else if ((c & 0xe0) == 0xc0) {
1247-
if ((s[i++] & 0xc0) != 0x80) {
1248-
return false;
1249-
}
1250-
} else if ((c & 0xf0) == 0xe0) {
1251-
if ((s[i++] & 0xc0) != 0x80 || (s[i++] & 0xc0) != 0x80) {
1252-
return false;
1253-
}
1254-
} else if ((c & 0xf8) == 0xf0) {
1255-
if ((s[i++] & 0xc0) != 0x80 || (s[i++] & 0xc0) != 0x80 || (s[i++] & 0xc0) != 0x80) {
1256-
return false;
1257-
}
1258-
} else {
1259-
return false;
1260-
}
1261-
}
1262-
return true;
1263-
}
1264-
12651239
zval *php_libxml_register_export(const zend_class_entry *ce, php_libxml_export_node export_function)
12661240
{
12671241
/* Initialize in case this module hasn't been loaded yet */

ext/libxml/php_libxml.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ PHP_LIBXML_API void php_libxml_ctx_warning(void *ctx, const char *msg, ...);
207207
PHP_LIBXML_API void php_libxml_pretend_ctx_error_ex(const char *file, int line, int column, const char *msg,...);
208208
PHP_LIBXML_API void php_libxml_ctx_error(void *ctx, const char *msg, ...);
209209
PHP_LIBXML_API void php_libxml_error_handler_va(php_libxml_error_level error_type, void *ctx, const char *msg, va_list args);
210-
PHP_LIBXML_API bool php_libxml_xmlCheckUTF8(const unsigned char *s);
211210
PHP_LIBXML_API void php_libxml_switch_context(const zval *context, zval *oldcontext);
212211
PHP_LIBXML_API void php_libxml_issue_error(int level, const char *msg);
213212
PHP_LIBXML_API bool php_libxml_disable_entity_loader(bool disable);

ext/soap/php_encoding.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ static xmlNodePtr to_xml_string(encodeTypePtr type, zval *data, int style, xmlNo
878878
xmlBufferFree(in);
879879
}
880880

881-
if (!php_libxml_xmlCheckUTF8(BAD_CAST(str))) {
881+
if (!xmlCheckUTF8(BAD_CAST str)) {
882882
char *err = emalloc(new_len + 8);
883883
char c;
884884
int i;

0 commit comments

Comments
 (0)