From 8d2c027089f4d1ddc07a1e19d1ccf06c356a5f11 Mon Sep 17 00:00:00 2001 From: Michael Fellinger Date: Sun, 7 Jun 2009 17:03:13 +0900 Subject: [PATCH 4/4] Fix replacing of  , aka   so it works on 1.9 --- lib/webrat/core/locators/link_locator.rb | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/webrat/core/locators/link_locator.rb b/lib/webrat/core/locators/link_locator.rb index 722aefc..a2e92a2 100644 --- a/lib/webrat/core/locators/link_locator.rb +++ b/lib/webrat/core/locators/link_locator.rb @@ -45,10 +45,14 @@ module Webrat end def replace_nbsp(str) - if str.respond_to?(:force_encoding) - str.force_encoding('UTF-8').gsub(/\xc2\xa0/u, ' ') + if str.respond_to?(:valid_encoding?) + if str.valid_encoding? + str.gsub(/\xc2\xa0/u, ' ') + else + str.force_encoding('UTF-8').gsub(/\xc2\xa0/u, ' ') + end else - str.gsub("\xc2\xa0", ' ') + str.gsub(/\xc2\xa0/u, ' ') end end -- 1.6.3.1