The My Opera forums have been replaced with forums.opera.com. Please head over there to discuss Opera's products and features

See the new Forums

Possible bug? Handling of images redirected to a server on 127.0.0.1:80 in "complex pages"

Forums » Opera for Windows/Mac/Linux » Beta testing (including snapshots and previews)

You need to be logged in to post in the forums. If you do not have an account, please sign up first.

Go to last post

1. November 2011, 22:09:38

cschmitz78

Posts: 14

Possible bug? Handling of images redirected to a server on 127.0.0.1:80 in "complex pages"

Hi,

I have mentioned some of this in an edit of an old post of mine, but I have broken my problem down further and would ask the experts to have a look at this test case scenario, maybe someone can tell me whether this sounds like a bug or expected behaviour. I have spent the entire day on this now and can't think of an explaination.

The following scenario uses a website at www.spiegel.de (German news site), but I have reproduced the issue with other sites. The former makes a good example because for the test case, one needs a website where (some) resources like images are coming from an alternate domain or subdomain. This is the case of spiegel.de, some images on spiegel.de come from cdn.spiegel.de. For this example, please note that there is a big image for the headline on www.spiegel.de (currently that is http://cdn.spiegel.de/images/image-277149-breitwandaufmacher-xqem.jpg), I will use this to describe the problem.

I have replicated this with Opera 12.00 Alpha Build 1116 (Opera Next), but also with 11.51 on Windows 7 64 bit.

I have disabled all caching (mem and disk cache off, check documents and check images both set to "always", private data repeatedly cleared and Opera restarted with just one tab). Opera Turbo is off.

So, the test case:

Step 1: in my Windows host file, I make an entry: 127.0.0.1 cdn.spiegel.de

This has obviously the effect to re-route HTTP requests to any resource on cdn.spiegel.de to my own machine.

Step 2: I installed a small webserver on my own machine, which listens on 127.0.0.1:80. I used the Abyss Web Server (http://www.aprelium.com/abyssws). I have put an image called "blocked.jpg" in its document root, its just a jpg of a small red letter "B" I made in mspaint. I verify that 127.0.0.1/blocked.jpg in Opera produces this image with the letter "B".

Step 3: I made a URL rewrite rule so that every URL with the regex "\.jpg$" that ends up being requested from the local Abyss web server gets rewritten into "/blocked.jpg", and ensure that rule processing stops if the url contains the string "blocked.jpg". The effect of this is that ANY jpg image URL (any without parameters at least) against cdn.spiegel.de (now 127.0.0.1) is delivered the blocked.jpg in response.

Step 4: When I open a tab and go to the URL "http://cdn.spiegel.de/images/image-277149-breitwandaufmacher-xqem.jpg", Opera renders my red letter "B"image, just the way I want.

Step 5: I made a small HTML file on my hard disk, and include the exact link that spiegel.de uses to include image-277149-breitwandaufmacher-xqem.jpg (copied from "inspect element" code), it looks like this:

<html>
<head>
</head>
<body>
<img src="http://cdn.spiegel.de/images/image-277149-breitwandaufmacher-xqem.jpg" width="860" 

height="320" border="0" title="Griechisches Referendum: Europa zittert vor dem Nein" 

alt="Griechisches Referendum: Europa zittert vor dem Nein"/>
</body>
</html>


I open this HTML file in Opera. At the image position, Opera renders my red letter "B" image (now scaled to 860*320 pixel). So far, so good.

Step 6: The problem. Open www.spiegel.de in Opera.

Observe that Opera does NOT render my blocked.jpg in the places where I expect it. Instead, it shows a sort of broken image frame, and the image properties show an image of 0x0 pixels with 0 bits of color. Why is that?

It can not be a mime type/image render problem because I have demonstrated in step 4 and 5 that the image is properly fetched and displayed by Opera. It is just NOT working like that in the context of www.spiegel.de. I tried the same thing with the thumbnails on Reddit and some images on Slashdot today (albeit with a different local web server) with the same result.

In all cases, the dreaded Internet Explorer, works as expected by me. If I go to www.spiegel.de in iexplore, all images coming from cdn.spiegel.de are replaced by the red "B"image (the blocked.jpg), its all over the website, as I expected it to be.

The background of all of this is, as you might have figured out, that I want to block ads and harmful content using my hosts file (with a tool such as http://www.abelhadigital.com/hostsman), and instead of "null-routing" the stuff to 127.0.0.1, I want to run a tiny web server on localhost with some rewrite rules, so that blocked content will be indicated as such by just throwing matching "blocked.jpg"-style images back instead of the original ad, or instead of dropping the connection (this returning of a block-image is also the idea behind HostServer.exe (part of the HostMan package), I used HostServer for testing earlier today, too, but its not configurable enough, hence I replaced it with the Abyss server).

I would really like to set this up with the hosts file blocks, and I am rather curious about the above now, so any input is much appreciated.

Thanks,
Carsten
If you can't avoid typing rm -rf / when you don't mean it, don't use shell.

Forums » Opera for Windows/Mac/Linux » Beta testing (including snapshots and previews)