Skip to content

Commit

Permalink
Introduce illegal_cdata error code
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Nov 16, 2019
1 parent 150cf8c commit a909107
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ private function process_node( DOMElement $node ) {
if ( ! empty( $cdata ) && $node instanceof DOMElement ) {
$validity = $this->validate_cdata_for_node( $node, $cdata );
if ( is_wp_error( $validity ) ) {
$this->remove_invalid_child( $node ); // @todo Code: illegal_cdata.
$this->remove_invalid_child( $node, [ 'code' => 'illegal_cdata' ] );
return null;
}
}
Expand Down
2 changes: 2 additions & 0 deletions includes/validation/class-amp-validation-error-taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -2936,6 +2936,8 @@ public static function get_error_title_from_code( $validation_error ) {
$title .= sprintf( ': <code>%s</code>', esc_html( $validation_error['property_name'] ) );
}
return $title;
case 'illegal_cdata':
return esc_html__( 'Illegal text content', 'amp' );
case 'illegal_css_important':
$title = esc_html__( 'Illegal CSS !important property', 'amp' );
if ( isset( $validation_error['property_name'] ) ) {
Expand Down
2 changes: 1 addition & 1 deletion tests/php/test-tag-and-attribute-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1909,10 +1909,10 @@ public function get_html_data() {
',
[ 'amp-bind' ],
[
'illegal_cdata',
'invalid_attribute',
'invalid_element',
'invalid_element',
'invalid_element',
],
];

Expand Down

0 comments on commit a909107

Please sign in to comment.