Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

image_tag adds strange dot after file names on windows

#693

On Windows, File#exist?("example.txt.") returns true, if example.txt exists (note the dot at the end). Because of that, methods like image_tag add a dot at the end of the file name.

Fix:

Change actionpack/lib/action_view/helpers/asset_tag_helper.rb:477 from:

              source += ".#{ext}" if ext && File.extname(source).blank? || File.exist?(File.join(ASSETS_DIR, dir, "#{source}.#{ext}"))

to:

              source += ".#{ext}" if ext && (File.extname(source).blank? || File.exist?(File.join(ASSETS_DIR, dir, "#{source}.#{ext}")))

Lots of assertions failed because of this in my app when I migrated from 1.2.6 to 2.1.0

Reported by iGEL · July 24th, 2008 @ 04:33 PM

State: duplicate
Milestone: 2.x
Assigned to: Pratik Pratik
Importance: none

Activity

  1. Pratik
    Pratik
    • Assigned user set to Pratik

    July 27th, 2008 @ 04:25 AM

  2. Liam Morley (carpeliam)
    Liam Morley (carpeliam)
    • Assigned user cleared.

    I just ran into this too. Because of the extra dot, the server doesn't consider 'myfile.png.?123456' to have a .png extension, and sets the content-type to 'application/octet-stream' instead of 'image/png', which means my images don't show up in some finicky mobile web browser, which makes me spend 2 hours hunting down this bug. :/

    Seem like this is more of a ruby bug than a rails bug, but the rails code could afford to be little tighter.

    July 27th, 2008 @ 04:42 AM

  3. Liam Morley (carpeliam)
  4. Aslak Hellesøy
    Aslak Hellesøy

    This is a Windows bug actually. Try this:

    IF EXIST README.txt..... echo Wind0s suX

    Awesome stuff

    August 25th, 2008 @ 03:39 PM

  5. Aslak Hellesøy
    Aslak Hellesøy

    Some interesting links mentioning trailing dots in file names on windows:

    http://www.fs-driver.org/relnote... http://osdir.com/ml/security.bug... (a 6 year old bug that they never really fixed, just worked around...)

    Since Redmond will probably never fix this bug, I guess the buest fix in Rails is to avoid code like

    File.exist?(File.join(ASSETS_DIR, dir, "#{source}.#{ext}"))

    When ext may be nil or an empty string...

    August 25th, 2008 @ 03:45 PM

  6. Pratik
    Pratik
    • State changed from new to stale
    • Tag changed from 2.1, actionpack, tested to 2.1, actionpack

    October 4th, 2008 @ 02:57 PM

  7. Pratik
    Pratik
    • State changed from stale to duplicate
    • Tag changed from 2.1, actionpack to 2.1, actionpack

    October 13th, 2008 @ 05:50 PM