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

Remove space from 'data: url()' in stylesheets #1164

Merged
merged 6 commits into from
May 26, 2018
Merged

Conversation

amedina
Copy link
Member

@amedina amedina commented May 21, 2018

Fixes #1089

@amedina amedina requested a review from westonruter May 26, 2018 20:27
* Test handling of stylesheets with spaces in the background-image URLs.
*
* @dataProvider get_data_urls
* @covers AMP_Style_Sanitizer::normalize_urls()
Copy link
Member

Choose a reason for hiding this comment

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

I think this is covering AMP_Style_Sanitizer::remove_spaces_from_data_urls() now, right?

* @param string $source Source URL string.
* @param string|null $expected Expected normalized URL string.
*/
public function test_normalize_urls( $source, $expected ) {
Copy link
Member

Choose a reason for hiding this comment

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

Likewise, test_ remove_spaces_from_data_urls

'url_with_spaces' => array(
'html { background-image:url(url with spaces.png); }',
'html{background-image:url("urlwithspaces.png")}',
),
Copy link
Member

Choose a reason for hiding this comment

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

Should include data: URL as discussed. Include spaces as reported in support forums.

if ( empty( $base_url ) ) {
return;
}
private function normalize_urls( $urls, $stylesheet_url = '' ) {
Copy link
Member

Choose a reason for hiding this comment

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

I think most of the changes to normalize_urls should be reverted back to real_path_urls because as we found out, the PHP CSS parser fails to parse URLs with spaces in them anyway, so this will never be fed any such URLs. The added comments should be retained, of course.

Copy link
Member Author

Choose a reason for hiding this comment

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

Reverted all, except some new code comments.

$options['stylesheet_url']
);
}
$this->normalize_urls(
Copy link
Member

Choose a reason for hiding this comment

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

Per below, I think this change can be reverted.

@amedina amedina changed the title [WIP] Remove space from 'data: url()' in stylesheets Remove space from 'data: url()' in stylesheets May 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants