From 520081c93eec6a01c740a148c91f5cf32e81aa0e Mon Sep 17 00:00:00 2001 From: Michael Fellinger Date: Sun, 7 Jun 2009 17:02:32 +0900 Subject: [PATCH 3/4] Don't use $LAST_MATCH_INFO since we don't require English.rb, use $~ instead --- lib/webrat/core/elements/link.rb | 2 +- lib/webrat/core/locators/link_locator.rb | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/webrat/core/elements/link.rb b/lib/webrat/core/elements/link.rb index 5b83e36..0edf8d4 100644 --- a/lib/webrat/core/elements/link.rb +++ b/lib/webrat/core/elements/link.rb @@ -53,7 +53,7 @@ module Webrat def authenticity_token return unless onclick && onclick.include?("s.setAttribute('name', 'authenticity_token');") && onclick =~ /s\.setAttribute\('value', '([a-f0-9]{40})'\);/ - $LAST_MATCH_INFO.captures.first + $~.captures.first end def onclick diff --git a/lib/webrat/core/locators/link_locator.rb b/lib/webrat/core/locators/link_locator.rb index 426c527..722aefc 100644 --- a/lib/webrat/core/locators/link_locator.rb +++ b/lib/webrat/core/locators/link_locator.rb @@ -45,7 +45,11 @@ module Webrat end def replace_nbsp(str) - str.gsub([0xA0].pack('U'), ' ') + if str.respond_to?(:force_encoding) + str.force_encoding('UTF-8').gsub(/\xc2\xa0/u, ' ') + else + str.gsub("\xc2\xa0", ' ') + end end def replace_nbsp_ref(str) -- 1.6.3.1