Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Mar 14, 2013 @ 15:50
    Rasmus Fjord
    0

    Imagegen(maybe) + IE + øæå = not returning image

    Hey there :) 

    We just discovered an issue that we havnt seen before, and we been using imagegen and a "few" sites now :)

    So lets say we have an image in our solution named "udendørs.jpg" and if i request this in IE like this : 

    http://localhost:15523/media/1341727/udendørs.jpg ;

    It works.

    But if the request is this :

    http://localhost:15523/imagegen.ashx?image=/media/1341727/udendørs.jpg

    it fails with this line : 

    File not found: /media/1341727/udendrs.jpg

    I understand why it fails because the image is not there under that given name. It only occurs in IE.

    Ive tried to check all settings that its UTF8 and other wierd things that could occur. Ive checked in on a local solution aswell and it also seems to be an issue their.

    I checked the http answer header : 

    ImageGenUrl /ImageGen.ashx?image=/media/1341727/udendørs.jpg&class=Articletop

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Mar 14, 2013 @ 15:58
    Rasmus Fjord
    0

    just a quick update the imagegen class on the image is the following 

    <Class Name="ArticleTop" OverridesQueryString="true">
            <Width>920</Width>
            <Height>520</Height>
        </Class>
  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Mar 14, 2013 @ 16:12
    Douglas Robar
    0

    Hi, Rasmus,

    Only an IE problem, eh? Why am I not surprised? :P

    Is it true in all versions of IE (7, 8, 9, and 10) or only older ones?

    I will have a look on my end and see what I can find out.

    cheers,
    doug. 

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Mar 14, 2013 @ 16:18
    Rasmus Fjord
    0

    Ofc its only in IE hehe (insert all curse words here followed by damn you IE)

    Yea ive tested it in IE7-9

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Mar 14, 2013 @ 16:23
    Douglas Robar
    0

    Just tried it on IE10... same problem. So that answers the question about which IE versions... all of them!

    This won't work in IE

    imagegen.ashx?image=/media/1341727/udendørs.jpg&width=200

    But when the filename is url-encoded like this it will:

    imagegen.ashx?image=/media/1341727/udend%C3%B8rs.jpg&width=200

     

    So the immediate solution might be to url-encode the filenames in the macro so that IE will respond properly.

    cheers,
    doug. 

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Mar 14, 2013 @ 16:28
    Rasmus Fjord
    0

    Yeah thought that would help will try to just encode it for now.

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Mar 15, 2013 @ 09:03
    Rasmus Fjord
    0

    Do you have a time horizon for a patch for it ? 

    The site we have this issue upon is not live yet but just if we should start running through all our macro's/extensions and such to implement a work around or if you have a fix comming in a few week or so.

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Mar 15, 2013 @ 09:12
    Rasmus Fjord
    0

    Another update, i noticed that it only occurs if we use &class option.

    And this workaround works : 

    @System.Web.HttpUtility.UrlEncode("/media/1341727/udendørs.jpg")

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Mar 15, 2013 @ 10:50
    Douglas Robar
    0

    I'm still trying to understand exactly what IE is doing differently than the other browsers so no patch in sight just yet.

    I have the problem all the time in IE, not just when using the &class option. Can you double-check if the &class option is making a difference? Or could it be any parameter, like the &width=200 parameter. That is, does it matter how many options you have on the querystring. You'll have image= of course (and that's enough for the error for me) and then you can add other params afterward. Does it have to be the &class= param or could it be anything?

    What I have found is that IE only has this problem with querystring parameters that contain unicode chars. In the main url you can have unicode but not in the querystring... those have to be url encoded. I tested this by renaming imagegen.ashx to udendørs.ashx and it worked exactly the same as before the rename. 

    My head scratcher at this point is when does the url encoding need to happen if someone is browsing a site with IE? Should all querystrings being passed into imagegen be url encoded in the html that IE then displays? Or is it something that imagegen's server-side process can handle? At the moment I *think* it must be corrected in the html markup before ImageGen gets involved at all. But I don't want to give up too early and maybe someone understands the IE request pipeline better than I do.

     

    One other question for you, Rasmus...

    Right now we are putting the imagegen request directly in the url of IE's browser. Does the same behaviour happen when you're displaying images on a web page (in a gallery that has an image with the udendørs.jpg filename, for instance)? If so, what happens if you specify the character set of the html page to allow unicode (I got this idea from http://stackoverflow.com/questions/7864505/ie-sends-character-instead-of-unicode-characters-in-http-get)? Any difference?

     

    cheers,
    doug. 

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Mar 15, 2013 @ 12:42
    Douglas Robar
    0
    1. More tests...

    If I have the following in my html markup (url-encoded automatically because I'm using a razor macro to generate the code in a gallery):

     

    <ahref="/imagegen.ashx?image=/media/2488/udend&#248;rs.jpg&width=415&height=450&pad=true">
        <imgsrc="/imagegen.ashx?image=/media/2488/udend&#248;rs.jpg&width=415&height=450&pad=true" />
    </a>
    1. The image displays properly
        
    2. If I click on the image to load the image via it's href, it also displays properly
      (interestingly, it displays the following UN-escaped url in the browser's url bar:
      /imagegen.ashx?image=/media/2488/udendørs.jpg&width=415&height=450&pad=true)
        
    3. If I then click within the url field in the browser and press the Enter key (with the imagegen'd image that displays correctly from step 2), boom. Doesn't work.
       (simply refreshing the browser will work, as it get's a 304 response) 

     

    I then added a hard-coded link to the template so that Razor wouldn't encode things:

    <a href="/imagegen.ashx?image=/media/2488/udendørs.jpg&width=415&height=450&pad=true">
       <img src="/imagegen.ashx?image=/media/2488/udendørs.jpg&width=415&height=450&pad=true" />
    </a>

    This behaved identically to the above.

     

     

    What do we learn from all this?

    1. The problem is with IE's ability to handle unicode characters in querystrings
    2. In the context of an <img> tag or an href within a web page there is no problem whatever
    3. Only when you try to type the url directly into IE is there a problem if it unicode characters in the querystring are not url encoded
    4. This is a problem that ImageGen itself cannot solve; it is an IE issue with querystrings

     

    I wonder if, in practice, this is a real problem that website users are likely to see?

    If they are, you might consider creating a simple url rewrite rule that includes the image name as part of the url itself (which IE will encode/unencode properly) and the rest of the imagegen parameters on the querystring as normal. Perhaps using a url something like this:

    /imagegen/media/2488/udendørs.jpg?width=415&height=450&pad=true

     

    cheers,
    doug. 

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Mar 15, 2013 @ 13:52
    Rasmus Fjord
    0

    Hey Doug 

    I did this test :

     <img src="/imagegen.ashx?image=/media/1341727/udendørs.jpg&width=200" />

    This one works, and this is why we havnt had the problem before with other customers. Because this is our first customer where we use class.

     <img src="/imagegen.ashx?image=/media/1341727/udendørs.jpg&class=GalleryThumbnail" />

    This one DOSNT work. So something is different when we use the CLASS property.

    BUT if i take the address directly in the browser then NEITHER works.

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Mar 15, 2013 @ 14:29
    Douglas Robar
    0

    Hi, Rasmus,

    Both of those work just fine for me. In IE10 at least. So I'm not reproducing the same thing you have :(

    Does it matter which class property you use? If not, what is in your GalleryThumbnail class (and any classes it inherits from)?

    cheers,
    doug. 

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Mar 18, 2013 @ 08:35
    Rasmus Fjord
    0

    Goood morning my friend :)

    Yeah i could see that they have it fixed in IE10.

    The GalleryThumbnail looks like this : 

      <Class Name="GalleryThumbnail" OverridesQueryString="true">
      <Width>110</Width>
        <Height>110</Height>
        <Constrain>False</Constrain>
        <Crop>Resize</Crop>
        <Align>Center</Align>
      </Class>

    And it dosnt inherit.

    Ive tried to write the same properties without using the class and it only confirms that the error must be in the class property : 

    The image is from IE9

    And the code for these 2 images looks like this :

    <img src="/imagegen.ashx?image=/media/1341727/udendørs.jpg&width=110&height=110&constrain=false&crop=resize&align=center" />
    <img src="/imagegen.ashx?image=/media/1341727/udendørs.jpg&class=GalleryThumbnail" />
  • Stephen Roberts 47 posts 516 karma points c-trib
    Mar 18, 2013 @ 11:31
    Stephen Roberts
    0

    I'm just going to butt in here. I was going to suggest this for nicer image urls. but actually I think it may help with your issue

     

    Add the following to UrlRewriting.config

    virtualUrl="^~/ImageGen/([\w|-]*)/(.*)" 

    rewriteUrlParameter="ExcludeFromClientQueryString" 

    destinationUrl="~/ImageGen.ashx?image=$2&class=$1" 

    ignoreCase="true" />

     

    Then you can access your imagegen images which have a class like site.com/Imagegen/CLASSNAME/media/2323/hot-naked-girls.jpg

    N.B. The regex will only allow you to have Any word character (letter, number, underscore) or an -

    My thinking is that this will stop ie from doing weird things to your param, Havnt tested it however.

     

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Mar 18, 2013 @ 12:15
    Rasmus Fjord
    0

    ill try it out immidietly

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Mar 18, 2013 @ 12:49
    Rasmus Fjord
    0

    Cant get it to work, this is the rule : 

      <add name="imagegenFix"  

           virtualUrl="^~/imagegen/([\w|-]*)/(.*)"

           rewriteUrlParameter="ExcludeFromClientQueryString"

           destinationUrl="~/imagegen.ashx?image=$2&amp;class=$1"

           ignoreCase="true" />

    and the URL : 
        <img src="/imagegen/GalleryThumbnail/media/1341727/udendørs.jpg" />
    It hits the redirect allright but this is what the header says : 
    Requested URL    http://localhost:15523/imagegen/gallerythumbnail/media/1341727/udendørs.jpg?image=media/1341727/udendørs.jpg&class=gallerythumbnail
    Physical Path

       C:\Dropbox\develop\Repos\Louis Poulsen\Umbraco\Umbraco.Site\imagegen\gallerythumbnail\media\1341727\udendørs.jpg

     

     

  • Stephen Roberts 47 posts 516 karma points c-trib
    Mar 18, 2013 @ 14:02
    Stephen Roberts
    0

    Thats really strange, I copied that snippet direct from a working project.

    Absolutely no idea why its doing that weirdness. Sorry :(

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Mar 18, 2013 @ 16:42
    Douglas Robar
    0

    I'm terrible at regex, but what Stephen has recommended is a good workaround and exactly what I'd mentioned earlier. Thanks for the regex, Stephen!

    But, since it isn't working properly (in a really weird way!), perhaps create the equivalent rewrite rule in the web.config file for IIS to handle directly rather than using Umbraco's urlrewriter? 

    cheers,
    doug. 

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Mar 19, 2013 @ 08:07
    Douglas Robar
    0

    Good morning, Rasmus!

    I've reinstalled IE9 and done a few tests. Copying your GalleryThumbnail class was essential to reproducing the problem, thank you.

    I haven't had a chance to look in-depth as to the reason, but for me, if I removed the <crop>Resize</crop> line from the class everything works properly ("resize" is the default mode for cropping so it doesn't need to be specified in this case).

    With a few more experiements, I also found that if I changed the <crop> entry to a bogus setting everything still worked properly. For instance, <crop>foobar</crop>.

    But when pasting in your class information afresh, the problem re-appeared.

    I then double-clicked the word "Resize" in the imagegen.config file so that the whole word was selected and deleted it. I then re-typed the word "Resize" and saved the config file. And guess what... it still worked properly!

    Though I can't see it, I can only guess there is something peculiar with a hidden character or some such nonsense in what you have in your config file and pasted into the forum. I don't understand it. But reliably for me, removing or replacing the "Resize" word in the class made things work properly. Only with your class as copied and pasted did I have a problem.

     

    So... can you try what I've tried and let me know what you find out?

    (in all cases, deleted the 'cached' folder and clear IE's browser cache to ensure you're seeing the fresh results of each change and not some cached result by either imagegen or the browser).

     

    cheers,
    doug. 

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Mar 19, 2013 @ 08:38
    Rasmus Fjord
    0

    Ey Doug :) 

    ive deleted "crop" from my class, cleaned the cache, added nocache=true but its still not working sadly :(

    Something ive noticed is that in IE it registeres the returned call as Text/html instead of image/jpeg.

     

    Here is the answer header : 

    And the "content" of the answer : 

     

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Mar 19, 2013 @ 08:39
    Rasmus Fjord
    0

    If when you got time we could easily skype/teamview half an hour to see if we could break the mystic :) Then you could also see the setup

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Mar 19, 2013 @ 08:49
    Douglas Robar
    0

    Well my friend, this one has me scratching my head. Perhaps a skype session would be best. Perhaps Wednesday mid-morning?

    BTW, it returns 'text' because that's what is being returned in the error condition... a text message rather than an image. So that's okay.

    cheers,
    doug. 

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Mar 19, 2013 @ 09:33
    Chriztian Steinmeier
    0

    Hi guys,

    Just a quick chip-in: I'm pretty much sure that IE is in fact doing the "correct" thing here (or atleast it thinks it does), in assuming that query parameters be URLEncoded — I've seen this a lot when modifying querystrings with JavaScript, and if we're using "unsafe" (word used in specs) characters, we are actually required to URLencode a key/value pair by encoding each part, so URLEncode("højde") + "=" + URLEncode("vældig meget") to get a URL component that would safely travel from A to B...

    Also done this in XSLT when re-applying values from the querystring to URLs generated within the page being rendered. 

    I don't know if it's a looser interpretation of some specs regarding Unicode charcters in URLs that makes the (all?) other browsers able to do the right thing...

    /Chriztian

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Mar 19, 2013 @ 09:40
    Rasmus Fjord
    0

    Hehe yea it is a real scratcher indeed :) 

    yeah lets have some skype and biscuits tomorrow morning. Shall we say 10 gmt+1 (9ish at your place im gussing?)

    You have my number hehe :)

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Apr 03, 2013 @ 11:25
    Rasmus Fjord
    101

    AHA ! 

    A SOLUTION HAS BEEN FOUND. 

    We are using the extension to imagegen "AdaptiveImaging for Imagegen"(https://bitbucket.org/Rasmusfjord/adaptiveimages-for-umbraco) and apparently when ØÆÅ is contained in the query params comming from a call from IE it messes with the url. So when the plugin calls  "context.Request.RawUrl" to get the full URL it changes the char's and in that way messes with it.

    A fix has been applied at bitbucket.

    Big cudos to Doug for spending a ton of time debugging with me :)

Please Sign in or register to post replies

Write your reply to:

Draft