Is there any way to disable image_tag''s automatic escaping of special html entities in it''s :alt tag? Example:>From the controller:@sale[''title''] = ''My Company Product©'' In the view: <%= image_tag(''path/to/file.png'', :alt => @sale[''title'']) %> Output: <img alt="My Company Product&copy;" src="/images/path/to/file.png" /> The helper automatically escapes the ampersand which is part of an already escaped character. Any ideas? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060616/76cdfeee/attachment.html
This happens way down in tag_helper.rb. def tag(name, options = nil, open = false) "<#{name}#{tag_options(options.stringify_keys) if options}" + (open ? ">" : " />") end The call to tag_options (a private method) is causing your pain. It''s kind of a big hammer, but you could write a little plugin that overrides this behavior. But remember, the behavior is there for a reason: To keep meddlesome little hackers from injecting unsave data into your pages. -- View this message in context: http://www.nabble.com/DISABLE-auto-escaping-in-image_tag-helper-t1795623.html#a4894908 Sent from the RubyOnRails Users forum at Nabble.com.
How about not escaping the data in the DB? After all, the escaping is for HTML. It certainly shouldn''t be escaped in the DB! Of course, I''m quite clear that this doesn''t solve your problem for your current data, but I''d certainly take a moment to figure out how to prevent this from happening in the future. -- -- Tom Mornini On Jun 15, 2006, at 5:58 PM, Jason T. Calhoun wrote:> Is there any way to disable image_tag''s automatic escaping of > special html entities in it''s :alt tag? > > Example: > > From the controller: > @sale[''title''] = ''My Company Product©'' > > In the view: > <%= image_tag(''path/to/file.png'', :alt => @sale[''title'']) %> > > Output: > <img alt="My Company Product&copy;" src="/images/path/to/ > file.png" /> > > The helper automatically escapes the ampersand which is part of an > already escaped character. Any ideas? > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails