Skip to content
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

WP_HTML_Tag_Processor: Inject dynamic data to block HTML markup in PHP #42485

Merged
merged 40 commits into from
Sep 23, 2022
Merged
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
4887c5c
Introduce `WP_HTML_Walker` for reliably modifying HTML attributes.
dmsnell Aug 12, 2022
3f148db
Add TODO for `/` in attribute area
dmsnell Aug 12, 2022
6d089f2
Add TODO for handling character references in `class` attribute
dmsnell Aug 12, 2022
2dbfa03
Add TODO for attribute escaping
dmsnell Aug 12, 2022
fadd51b
Ignore slashes when parsing attribute names
adamziel Aug 15, 2022
17879e8
Remove test_get_tag_returns_raw_open_tag_name as get_tag always retur…
adamziel Aug 15, 2022
bdd56a6
Correctly check the indices of <!-- characters in skip_script_data -
adamziel Aug 15, 2022
8a48fab
Fix linting issues
gziolo Aug 16, 2022
e9a71d6
Improve existing unit tests
gziolo Aug 16, 2022
9bcfd3a
Don't close the walker in the __toString() method
adamziel Aug 18, 2022
f6d1bcc
Code style update
adamziel Aug 18, 2022
541d86b
Update phpunit/html/wp-html-walker-test.php
adamziel Aug 19, 2022
cdd8ae0
Update phpunit/html/wp-html-walker-test.php
adamziel Aug 19, 2022
1852cf7
Update lib/experimental/html/class-wp-html-walker.php
adamziel Aug 19, 2022
6c4647d
Update lib/experimental/html/class-wp-html-walker.php
adamziel Aug 19, 2022
4554dd3
Update lib/experimental/html/class-wp-html-walker.php
dmsnell Sep 22, 2022
e2eb423
Refactor early-abort to remove level of nesting
dmsnell Sep 22, 2022
68b55c4
Rewrite code to separate stages of computation
dmsnell Sep 22, 2022
f664c08
Expand name of $c to $character
dmsnell Sep 22, 2022
147647b
typo: type of integer is `int`
dmsnell Sep 22, 2022
d8b8ddd
typo: type of integer is `int`
dmsnell Sep 22, 2022
a325fa3
Reorder the test methods
adamziel Sep 23, 2022
a4fb703
Add the missing error messages
adamziel Sep 23, 2022
c017420
Reorder tests to keep set_attribute tests grouped together
adamziel Sep 23, 2022
07041ee
Update phpunit/html/wp-html-walker-test.php
adamziel Sep 23, 2022
63f4e34
Update phpunit/html/wp-html-walker-test.php
adamziel Sep 23, 2022
1021d9b
Update phpunit/html/wp-html-walker-test.php
adamziel Sep 23, 2022
e0910be
Explain the test_set_attribute_takes_priority_over_add_class test
adamziel Sep 23, 2022
273c502
Merge branch 'add/html-tokenizer-2' of github.com:WordPress/gutenberg…
adamziel Sep 23, 2022
19a8546
Rename test_works_with_single_quote_marks to test_parses_html_attribu…
adamziel Sep 23, 2022
c96f08b
Update the test names to suggest the failure mode
adamziel Sep 23, 2022
218afe4
Update phpunit/html/wp-html-walker-test.php
adamziel Sep 23, 2022
81d43e2
Add covers annotations
adamziel Sep 23, 2022
53143f8
Rename WP_HTML_Walker to WP_HTML_Tag_Processor
adamziel Sep 23, 2022
bddc2db
Remove the is_closed method, as the idea of a closed walker does not …
adamziel Sep 23, 2022
f299bf0
Update lib/experimental/html/class-wp-html-text-replacement.php
adamziel Sep 23, 2022
13c3270
Update lib/experimental/html/class-wp-html-attribute-token.php
adamziel Sep 23, 2022
5c2d080
Rename $w to $p
adamziel Sep 23, 2022
509684c
Merge branch 'add/html-tokenizer-2' of github.com:WordPress/gutenberg…
adamziel Sep 23, 2022
d9d3bab
Rename phpdoc references to $w to $p
adamziel Sep 23, 2022
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
Prev Previous commit
Next Next commit
Rewrite code to separate stages of computation
  • Loading branch information
dmsnell committed Sep 22, 2022

Verified

This commit was signed with the committer’s verified signature. The key has expired.
mmarchini mary marchini
commit 68b55c41f17bde95907d0b294a726123ca432b67
11 changes: 8 additions & 3 deletions lib/experimental/html/class-wp-html-walker.php
Original file line number Diff line number Diff line change
@@ -929,9 +929,14 @@ public function get_attribute( $name ) {
* @return string|null Name of current tag in input HTML, or `null` if none currently open.
*/
public function get_tag() {
return null !== $this->tag_name_starts_at
? strtolower( substr( $this->html, $this->tag_name_starts_at, $this->tag_name_ends_at - $this->tag_name_starts_at ) )
: null;
if ( null === $this->tag_name_starts_at ) {
return null;
}

$tag_name_length = $this->tag_name_ends_at - $this->tag_name_starts_at;
$tag_name = substr( $this->html, $this->tag_name_starts_at, $tag_name_length );

return strtolower( $tag_name );
}

/**