aboutsummaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
authorMatthew Landauer <matthew@openaustralia.org>2013-03-25 17:49:34 +1100
committerMatthew Landauer <matthew@openaustralia.org>2013-03-25 17:57:12 +1100
commit349348ef2d78906eaa707b95e829d4892dce0580 (patch)
treeab0539895b2b7bc4e5bd6fddaed8bd74d527b2ed /vendor
parentd09758c79fff462906b48dda6601ced25a8865da (diff)
Fix word highlighting in acts_as_xapian for non-ascii characters. Fixes #505
Diffstat (limited to 'vendor')
-rw-r--r--vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb
index 9eaedcf9e..e05406181 100644
--- a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb
+++ b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb
@@ -1,3 +1,4 @@
+# encoding: utf-8
# acts_as_xapian/lib/acts_as_xapian.rb:
# Xapian full text search in Ruby on Rails.
#
@@ -472,7 +473,9 @@ module ActsAsXapian
# date ranges or similar. Use this for cheap highlighting with
# TextHelper::highlight, and excerpt.
def words_to_highlight
- query_nopunc = self.query_string.gsub(/[^a-z0-9:\.\/_]/i, " ")
+ # TODO: In Ruby 1.9 we can do matching of any unicode letter with \p{L}
+ # But we still need to support ruby 1.8 for the time being so...
+ query_nopunc = self.query_string.gsub(/[^ёЁа-яА-Яa-zA-Zà-üÀ-Ü0-9:\.\/_]/iu, " ")
query_nopunc = query_nopunc.gsub(/\s+/, " ")
words = query_nopunc.split(" ")
# Remove anything with a :, . or / in it