HTML API: Prevent bookmark exhaustion from throwing.
When bookmark exhaustion occurs during processing, return `false` instead of throwing an `Exception`. Developed in https://github.com/WordPress/wordpress-develop/pull/10616. Props jonsurrell, westonruter, dmsnell. Fixes #64394. Built from https://develop.svn.wordpress.org/trunk@61755 git-svn-id: http://core.svn.wordpress.org/trunk@61061 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -1042,8 +1042,17 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
|
||||
$token_name = $this->get_token_name();
|
||||
|
||||
if ( self::REPROCESS_CURRENT_NODE !== $node_to_process ) {
|
||||
try {
|
||||
$bookmark_name = $this->bookmark_token();
|
||||
} catch ( Exception $e ) {
|
||||
if ( self::ERROR_EXCEEDED_MAX_BOOKMARKS === $this->last_error ) {
|
||||
return false;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$this->state->current_token = new WP_HTML_Token(
|
||||
$this->bookmark_token(),
|
||||
$bookmark_name,
|
||||
$token_name,
|
||||
$this->has_self_closing_flag(),
|
||||
$this->release_internal_bookmark_on_destruct
|
||||
@@ -1153,6 +1162,12 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
|
||||
* otherwise might involve messier calling and return conventions.
|
||||
*/
|
||||
return false;
|
||||
} catch ( Exception $e ) {
|
||||
if ( self::ERROR_EXCEEDED_MAX_BOOKMARKS === $this->last_error ) {
|
||||
return false;
|
||||
}
|
||||
// Rethrow any other exceptions for higher-level handling.
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6315,6 +6330,8 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
|
||||
*
|
||||
* @since 6.7.0
|
||||
*
|
||||
* @throws Exception When unable to allocate a bookmark for the next token in the input HTML document.
|
||||
*
|
||||
* @param string $token_name Name of token to create and insert into the stack of open elements.
|
||||
* @param string|null $bookmark_name Optional. Name to give bookmark for created virtual node.
|
||||
* Defaults to auto-creating a bookmark name.
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '7.0-beta2-61754';
|
||||
$wp_version = '7.0-beta2-61755';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
||||
Reference in New Issue
Block a user