Skip to content

Remove custom UTF-8 check function from ext/libxml #18706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ PHP 8.5 INTERNALS UPGRADE NOTES

- ext/libxml
. The refcount APIs now return an `unsigned int` instead of an `int`.
. Removed php_libxml_xmlCheckUTF8(). Use xmlCheckUTF8() from libxml instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really not have an exported UTF-8 checking function ourselves?! I checked and couldn't find anything.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really not have an exported UTF-8 checking function ourselves?! I checked and couldn't find anything.

We have some mbstring APIs that AFAIK are exported, but then you need mbstring loaded..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we'll have some due to ext/lexbor in master


- ext/pdo
. Added `php_pdo_stmt_valid_db_obj_handle()` to check if the database object
Expand Down
26 changes: 0 additions & 26 deletions ext/libxml/libxml.c
Original file line number Diff line number Diff line change
Expand Up @@ -1236,32 +1236,6 @@ PHP_FUNCTION(libxml_get_external_entity_loader)
/* }}} */

/* {{{ Common functions shared by extensions */
bool php_libxml_xmlCheckUTF8(const unsigned char *s)
{
size_t i;
unsigned char c;

for (i = 0; (c = s[i++]);) {
if ((c & 0x80) == 0) {
} else if ((c & 0xe0) == 0xc0) {
if ((s[i++] & 0xc0) != 0x80) {
return false;
}
} else if ((c & 0xf0) == 0xe0) {
if ((s[i++] & 0xc0) != 0x80 || (s[i++] & 0xc0) != 0x80) {
return false;
}
} else if ((c & 0xf8) == 0xf0) {
if ((s[i++] & 0xc0) != 0x80 || (s[i++] & 0xc0) != 0x80 || (s[i++] & 0xc0) != 0x80) {
return false;
}
} else {
return false;
}
}
return true;
}

zval *php_libxml_register_export(const zend_class_entry *ce, php_libxml_export_node export_function)
{
/* Initialize in case this module hasn't been loaded yet */
Expand Down
1 change: 0 additions & 1 deletion ext/libxml/php_libxml.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ PHP_LIBXML_API void php_libxml_ctx_warning(void *ctx, const char *msg, ...);
PHP_LIBXML_API void php_libxml_pretend_ctx_error_ex(const char *file, int line, int column, const char *msg,...);
PHP_LIBXML_API void php_libxml_ctx_error(void *ctx, const char *msg, ...);
PHP_LIBXML_API void php_libxml_error_handler_va(php_libxml_error_level error_type, void *ctx, const char *msg, va_list args);
PHP_LIBXML_API bool php_libxml_xmlCheckUTF8(const unsigned char *s);
PHP_LIBXML_API void php_libxml_switch_context(const zval *context, zval *oldcontext);
PHP_LIBXML_API void php_libxml_issue_error(int level, const char *msg);
PHP_LIBXML_API bool php_libxml_disable_entity_loader(bool disable);
Expand Down
2 changes: 1 addition & 1 deletion ext/soap/php_encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ static xmlNodePtr to_xml_string(encodeTypePtr type, zval *data, int style, xmlNo
xmlBufferFree(in);
}

if (!php_libxml_xmlCheckUTF8(BAD_CAST(str))) {
if (!xmlCheckUTF8(BAD_CAST str)) {
char *err = emalloc(new_len + 8);
char c;
int i;
Expand Down