rails/rails — pull request #10037 by wangjohn (2013-04-01 22:55:29+00:00)
Title: Refactoring the selector.rb file for the HTML sanitizer

Right now, the HTML sanitizer is incredibly hard to read. This PR is a small step towards making it better.

A lot of the code that was used in the ``Selector`` class was repeated. I've refactored some of this code into new protected helper methods. The ``concatenate_subset_to_matches!`` method refactors code that was basically copy and pasted in 3 different locations.

I've also changed some ``for`` loops into ``each`` blocks, since in ``for`` loops, the iterator variable persists after the loop has been completed. There's no reason to do this in the ``match`` method (since those variables aren't used later).