Skip to content
6 changes: 6 additions & 0 deletions src/wp-includes/html-api/class-wp-html-tag-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -3197,6 +3197,12 @@ public function set_attribute( $name, $value ): bool {
* @see https://html.spec.whatwg.org/#attributes-3
*/
$escaped_new_value = in_array( $comparable_name, wp_kses_uri_attributes() ) ? esc_url( $value ) : esc_attr( $value );

// If the escaping functions wiped out the update, reject it and indicate it was rejected.
if ( '' === $escaped_new_value && '' !== $value ) {
return false;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this looks almost complete! what happens if someone supplies '' as the new value? Maybe we need to check to make sure that $escaped_new_value !== $value && '' === $escaped_new_value?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for pointing it out. I have updated it.


$updated_attribute = "{$name}=\"{$escaped_new_value}\"";
}

Expand Down