Version 1.0.2 breaks when using AdBlock 2.5.19 in webkit #49

Open
chapati23 opened this Issue Feb 21, 2012 · 4 comments

3 participants

@chapati23

When using the Safari/Chrome Extension AdBlock there is an error on line 67 in prefixfree.js

  • XMLHttpRequest cannot load data:text/css,. Cross origin requests are only supported for HTTP
  • 67NETWORK_ERR: XMLHttpRequest Exception 101: A network error occured in synchronous requests.

The Issue is, that AdBlock seems to create a link element between the head and the body
link type="text/css" rel="stylesheet" href="data:text/css,"

I guess prefixfree tries to do something with it and then the error occurs.

Of course u could just deactivate AdBlock but IMO that's a pretty common Extension to have so maybe we should try to find a workaround.

Version 1.0.1 worked fine btw

@LeaVerou
Owner

Wow, that looks really hard to solve. WebKit erroneously treats data: URIs as cross-origin, and since they are local, you can't even fix it with CORS. It's a well-known WebKit bug, and I really hope they fix it. What you mean by "it worked in 1.0.1 was that there was no error, not that the outcome was different, right?

Actually, now that I think of it, the only way to solve it would be to manually parse the data URI. Not nice, but certainly not impossible. Hmm. Can you give me an example of those URIs? Is it URL-encoded or base64 encoded?

@LeaVerou
Owner

Btw, what are these data: URIs that AdBlock adds? Do they need prefixing? If not I could just check if the URL is a data URI and avoid messing with it if it is, or something like that.

@chapati23

yeah. 1.0.1 just didn't throw any errors. i don't really know why they need this strange data-uri link-tag. maybe some javascript pastes some styles in it to hide certain ads or banners?

i wouldn't think the added styles need prefixing as the plugin owner hopefully took care of that.

the strange thing is, i can only see the link-tag in the inspector. when i do view source from the context menu i don't see it.

maybe check the source if it helps: http://code.google.com/p/adblockforchrome/

@joelpurra

Just had the same problem here. This is what I can see injected in my page, by adblock.

<link type="text/css" rel="stylesheet" href="data:text/css,">

The adblock stuff does not need to be parsed by prefixfree, as they don't do anything but hide ads with #some-ad, .other-ads { display: none; } or similar. (The exact css is not visible though, but it used to look something like that.)

So, my naïve fix for now is just block skip exactly that url.

prefixfree.js at line 29

if (url === "data:text/css,") {
  return;
}

I've forked prefixfree with this fix and will issue a pull request in case you guys see use for it in the official version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment