rails/rails — pull request #15654 by pdg137 (2014-06-11 21:28:29+00:00)
Title: In tag helper, honor html_safe on array parameters

Currently, the tag helper honors the html_safe on its parameter values, so you can do something like `tag('a', href: 'http://example.com?a&b'.html_safe)`. However, with array values (_e.g._ when supplying multiple classes) the strings are concatenated together with `Array#join` and escaped without regard to the prior `html_safe` status. This patch resolves the inconsistent behavior, as demonstrated by several tests. I have also included a test for the empty array, since that's an easy one to break if you do it wrong.

I can't actually see a valid use case for supplying `html_safe` string values; in my opinion people should just supply the raw string and not try to micromanage how Rails escapes strings when using these helpers. However, as long as we are going to escape values sometimes, we should do it consistently.