diff --git a/includes/sanitizers/class-amp-iframe-sanitizer.php b/includes/sanitizers/class-amp-iframe-sanitizer.php
index 17d1b9ff257..e841596e642 100644
--- a/includes/sanitizers/class-amp-iframe-sanitizer.php
+++ b/includes/sanitizers/class-amp-iframe-sanitizer.php
@@ -126,7 +126,8 @@ public function sanitize() {
* @return array Returns HTML attributes; removes any not specifically declared above from input.
*/
private function filter_attributes( $attributes ) {
- $out = array();
+ $out = array();
+ $out['style'] = 'max-width:100%'; // AMP_Style_Sanitizer will move this to the amp-custom style.
foreach ( $attributes as $name => $value ) {
switch ( $name ) {
diff --git a/tests/test-amp-iframe-sanitizer.php b/tests/test-amp-iframe-sanitizer.php
index 7748462ca4a..1bdda928309 100644
--- a/tests/test-amp-iframe-sanitizer.php
+++ b/tests/test-amp-iframe-sanitizer.php
@@ -10,57 +10,57 @@ public function get_data() {
'simple_iframe' => array(
'',
- '',
+ '',
),
'force_https' => array(
'',
- '',
+ '',
),
'iframe_without_dimensions' => array(
'',
- '',
+ '',
),
'iframe_with_height_only' => array(
'',
- '',
+ '',
),
'iframe_with_width_only' => array(
'',
- '',
+ '',
),
'iframe_with_invalid_frameborder' => array(
'',
- '',
+ '',
),
'iframe_with_1_frameborder' => array(
'',
- '',
+ '',
),
'simple_iframe_with_sandbox' => array(
'',
- '',
+ '',
),
'iframe_with_blacklisted_attribute' => array(
'',
- '',
+ '',
),
'iframe_with_sizes_attribute_is_overridden' => array(
'',
- '',
+ '',
),
'iframe_with_protocol_relative_url' => array(
'',
- '',
+ '',
),
'multiple_same_iframe' => array(
@@ -69,7 +69,7 @@ public function get_data() {
',
- '',
+ '',
),
'multiple_different_iframes' => array(
@@ -78,19 +78,19 @@ public function get_data() {
',
- '',
+ '',
),
'iframe_in_p_tag' => array(
'
',
- '',
+ '',
),
'multiple_iframes_in_p_tag' => array(
'',
- '',
+ '',
),
'multiple_iframes_and_contents_in_p_tag' => array(
'contents
',
- 'contents
',
+ 'contents
',
),
);
}
@@ -160,7 +160,7 @@ public function test_get_scripts__did_convert() {
public function test__args__placeholder() {
$source = '';
- $expected = '';
+ $expected = '';
$dom = AMP_DOM_Utils::get_dom_from_content( $source );
$sanitizer = new AMP_Iframe_Sanitizer( $dom, array(