-
Notifications
You must be signed in to change notification settings - Fork 3.3k
HTML API: Ensure bookmark exaustion does not error #10616
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
base: trunk
Are you sure you want to change the base?
Changes from 9 commits
2c9a17d
da53752
0337b13
4101235
e7d649c
1cfeb85
17bbca8
ba480a5
ff7657f
b02d679
9e042f3
c7710aa
1681fed
3f6bffd
aefc5bf
6d1f860
207f04f
cbab9c1
c578125
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1040,8 +1040,17 @@ public function step( $node_to_process = self::PROCESS_NEXT_NODE ): bool { | |
| $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 | ||
|
|
@@ -1151,6 +1160,12 @@ public function step( $node_to_process = self::PROCESS_NEXT_NODE ): bool { | |
| * 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; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -6287,6 +6302,8 @@ private function insert_foreign_element( WP_HTML_Token $token, bool $only_add_to | |
| * | ||
| * @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. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.