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

HTML API: Add custom text decoder #6387

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3ff78cc
HTML API: Add custom text decoder.
dmsnell Apr 24, 2024
401d30f
Correct typo in max digit computation.
dmsnell May 15, 2024
4f5f21e
Adjust docs, names.
dmsnell May 24, 2024
72aeccd
Updates to attribute_starts_with
dmsnell May 25, 2024
d60e320
Add tests for attribute_starts_with
dmsnell May 28, 2024
db384b9
Fix alignment lint
sirreal May 28, 2024
be8b2a5
Annotate global variable type
sirreal May 28, 2024
8f9b076
Change read_character_reference return type to string|false
sirreal May 28, 2024
2d3dee1
Merge remote-tracking branch 'upstream/trunk' into html-api/add-text-…
sirreal May 28, 2024
b559320
Replace &colon entity test with ∷
sirreal May 28, 2024
53dafce
Remove ∷ test (this means "∷"!)
sirreal May 28, 2024
3bf0434
Add WIP test for edge cases.
dmsnell May 28, 2024
edbc0b0
Fix type error in text decoder
dmsnell May 28, 2024
fd83c46
Replace false with null for token reading.
dmsnell May 29, 2024
59671d6
Update tests for Token Map returning null.
dmsnell May 29, 2024
ab672e7
Fill in test phpdoc details
sirreal May 29, 2024
2e2fb8b
Update optional $case_sensitivity param types
sirreal May 29, 2024
d38df36
Fix optional @param types
sirreal May 29, 2024
9931e09
Use default argument for read_character_reference at
sirreal May 29, 2024
95820aa
Add additional attribute prefix tests
sirreal May 29, 2024
47dcdc1
Change byte_length_of_matched_token to matched_token_byte_length
sirreal May 29, 2024
0c0b36c
Docblock cleanup
dmsnell May 31, 2024
f594b87
Merge remote-tracking branch 'upstream/trunk' into html-api/add-text-…
dmsnell Jun 2, 2024
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
10 changes: 5 additions & 5 deletions src/wp-includes/class-wp-token-map.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ public function contains( $word, $case_sensitivity = 'case-sensitive' ) {
* @param ?int $offset How many bytes into the string where the lookup key ought to start.
* @param ?int &$matched_token_byte_length Holds byte-length of found token matched, otherwise not set.
* @param ?string $case_sensitivity 'ascii-case-insensitive' to ignore ASCII case or default of 'case-sensitive'.
* @return string|false Mapped value of lookup key if found, otherwise `false`.
* @return string|null Mapped value of lookup key if found, otherwise `null`.
*/
public function read_token( $text, $offset = 0, &$matched_token_byte_length = null, $case_sensitivity = 'case-sensitive' ) {
$ignore_case = 'ascii-case-insensitive' === $case_sensitivity;
Expand All @@ -539,7 +539,7 @@ public function read_token( $text, $offset = 0, &$matched_token_byte_length = nu
// Perhaps a short word then.
return strlen( $this->small_words ) > 0
? $this->read_small_token( $text, $offset, $matched_token_byte_length, $case_sensitivity )
: false;
: null;
}

$group = $this->large_words[ $group_at / ( $this->key_length + 1 ) ];
Expand All @@ -564,7 +564,7 @@ public function read_token( $text, $offset = 0, &$matched_token_byte_length = nu
// Perhaps a short word then.
return strlen( $this->small_words ) > 0
? $this->read_small_token( $text, $offset, $matched_token_byte_length, $case_sensitivity )
: false;
: null;
}

/**
Expand All @@ -576,7 +576,7 @@ public function read_token( $text, $offset = 0, &$matched_token_byte_length = nu
* @param ?int $offset How many bytes into the string where the lookup key ought to start.
* @param ?int &$matched_token_byte_length Holds byte-length of found lookup key if matched, otherwise not set.
* @param ?string $case_sensitivity 'ascii-case-insensitive' to ignore ASCII case or default of 'case-sensitive'.
* @return string|false Mapped value of lookup key if found, otherwise `false`.
* @return string|null Mapped value of lookup key if found, otherwise `null`.
*/
private function read_small_token( $text, $offset, &$matched_token_byte_length, $case_sensitivity = 'case-sensitive' ) {
$ignore_case = 'ascii-case-insensitive' === $case_sensitivity;
Expand Down Expand Up @@ -616,7 +616,7 @@ private function read_small_token( $text, $offset, &$matched_token_byte_length,
return $this->small_mappings[ $at / ( $this->key_length + 1 ) ];
}

return false;
return null;
}

/**
Expand Down
Loading
Loading