Not filing this as a bug, but simply as confusion.

In the mongrel.rb, you have a comment that says this about the
self.escape method:

    # Performs URI escaping so that you can construct proper
    # query strings faster.  Use this rather than the cgi.rb
    # version since it's faster.  (Stolen from Camping).
    def self.escape(s)
      s.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/n) {
        '%'+$1.unpack('H2'*$1.size).join('%').upcase
      }.tr(' ', '+')
    end

That "Stolen from Camping" thing perplexed me, because when I looked
at that, it looked fundamentally identical to what I have in IOWA,
which definitely was not stolen from camping.

Here's the code from Iowa::Util.escape()

    def Util.escape(string)
      string.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/n) do
        '%' + $1.unpack('H2' * $1.size).join('%').upcase
      end.tr(' ', '+')
    end

Now, the funny thing here is that I just stole this from cgi.rb so
that it would be available without having to require all of CGI.
Here's the original code from cgi.rb:

  def CGI::escape(string)
    string.gsub(/([^ a-zA-Z0-9_.-]+)/n) do
      '%' + $1.unpack('H2' * $1.size).join('%').upcase
    end.tr(' ', '+')
  end

Camping simply stole from cgi.rb, too, so Camping's escape() can't be
any faster than CGI's, and the comment in mongrel.rb should probably
reflect this.


Kirk Haines
_______________________________________________
Mongrel-users mailing list
Mongrel-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-users

Reply via email to