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

URI rewriter thinks protocol agnostic URIs like //fonts.googleapis.com are internal #23

Open
lkraav opened this issue Aug 22, 2013 · 5 comments
Labels

Comments

@lkraav
Copy link

lkraav commented Aug 22, 2013

This is crucial, because Firefox 23 actively blocks mixed content, leading to decidedly bad UX.

Try enqueueing something like "//fonts.googleapis.com/css?family=Lato:300,400|Open+Sans:300".

Dep. Minification admin panel will be filled with errors "Request for http://domain.com//fonts.googleapis.com/css?family=Lato:300,400 returned with HTTP 404 Not Found Try again"

@westonruter
Copy link
Contributor

Yes, excellent. I ran into this issue myself and had to force the protocol to be added each time. It shouldn't be too difficult to fix, and from looking at the code I'm not sure why this is happening. I think the problem is happening here:

$has_host = (bool) parse_url( $src, PHP_URL_HOST );
if ( ! $has_host ) {
    $src = 'http://' . $host_domain . $src;
}

However, it seems that parse_url is properly detecting scheme-less URLs:

wp> parse_url( '//example.com/foo/bar', PHP_URL_HOST )
string(11) "example.com"

Oh, I see what the problem is. Looking at the parse_url docs:

5.4.7 Fixed host recognition when scheme is omitted and a leading component separator is present.

So to be compatible with PHP<5.4.7, we need to make the $has_host condition something like:

$has_host = ( (bool) parse_url( $src, PHP_URL_HOST ) || strpos( $src, '//' ) === 0 )

@lkraav
Copy link
Author

lkraav commented Aug 23, 2013

I'm going to test this approach

@lkraav
Copy link
Author

lkraav commented Aug 23, 2013

It appears is_self_hosted_src() also requires help.

@lkraav
Copy link
Author

lkraav commented Aug 23, 2013

Adding the same

if ( strpos( $src, '//' ) === 0 ) return false;

in front of existing is_self_hosted_src() logic seems to stop the plugin from coughing blood.

@lkraav
Copy link
Author

lkraav commented Apr 30, 2014

Since WPEngine is known to lag behind time with their 5.3 thing, I'm going to try to address this with a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants