| Server IP : 213.186.33.4 / Your IP : 216.73.216.222 Web Server : Apache System : Linux webm005.cluster103.gra.hosting.ovh.net 6.18.39-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Tue Jul 21 12:03:15 CEST 2026 x86_64 User : karinebmkh ( 644538) PHP Version : 8.4.22 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/karinebmkh/www2/wp-content/plugins/amp/includes/sanitizers/ |
Upload File : |
<?php
/**
* Class AMP_Script_Sanitizer
*
* @since 1.0
* @package AMP
*/
/**
* Class AMP_Script_Sanitizer
*
* @since 1.0
*/
class AMP_Script_Sanitizer extends AMP_Base_Sanitizer {
/**
* Sanitize noscript elements.
*
* Eventually this should also handle script elements, if there is a known AMP equivalent.
* If nothing is done with script elements, the whitelist sanitizer will deal with them ultimately.
*
* @todo Eventually this try to automatically convert script tags to AMP when they are recognized. See <https://github.com/ampproject/amp-wp/issues/1032>.
* @todo When a script has an adjacent noscript, consider removing the script here to prevent validation error later. See <https://github.com/ampproject/amp-wp/issues/1213>.
*
* @since 1.0
*/
public function sanitize() {
$noscripts = $this->dom->getElementsByTagName( 'noscript' );
for ( $i = $noscripts->length - 1; $i >= 0; $i-- ) {
$noscript = $noscripts->item( $i );
// Skip AMP boilerplate.
if ( $noscript->firstChild instanceof DOMElement && $noscript->firstChild->hasAttribute( 'amp-boilerplate' ) ) {
continue;
}
$fragment = $this->dom->createDocumentFragment();
$fragment->appendChild( $this->dom->createComment( 'noscript' ) );
while ( $noscript->firstChild ) {
$fragment->appendChild( $noscript->firstChild );
}
$fragment->appendChild( $this->dom->createComment( '/noscript' ) );
$noscript->parentNode->replaceChild( $fragment, $noscript );
$this->did_convert_elements = true;
}
}
}