This project is archived and is in readonly mode.
image_tag adds strange dot after file names on windows
Reported by iGEL | July 24th, 2008 @ 04:33 PM | in 2.x
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
Comments and changes to this ticket
-
Pratik July 27th, 2008 @ 04:25 AM
- Assigned user set to Pratik
-
Liam Morley (carpeliam) July 27th, 2008 @ 04:42 AM
- 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.
-
Liam Morley (carpeliam) July 27th, 2008 @ 04:42 AM
- Assigned user set to Pratik
-
Aslak Hellesøy August 25th, 2008 @ 03:39 PM
This is a Windows bug actually. Try this:
IF EXIST README.txt..... echo Wind0s suX
Awesome stuff
-
Aslak Hellesøy August 25th, 2008 @ 03:45 PM
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...
-
Pratik October 4th, 2008 @ 02:57 PM
- State changed from new to stale
- Tag changed from 2.1, actionpack, tested to 2.1, actionpack
-
Pratik October 13th, 2008 @ 05:50 PM
- State changed from stale to duplicate
- Tag changed from 2.1, actionpack to 2.1, actionpack
Fixed in http://github.com/rails/rails/co...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>