From 421e50d2ca97dea16287654e3eff05d9a2f35e3f Mon Sep 17 00:00:00 2001 From: MrZYX Date: Sat, 26 Mar 2011 19:02:04 +0100 Subject: [PATCH] specify what we don't want in a tag for now --- lib/diaspora/taggable.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/diaspora/taggable.rb b/lib/diaspora/taggable.rb index 9704681ed..e77c599d3 100644 --- a/lib/diaspora/taggable.rb +++ b/lib/diaspora/taggable.rb @@ -4,6 +4,8 @@ module Diaspora module Taggable + VALID_TAG_BODY = /[^_\s#*\[\]()\:\@\/"']+/ + def self.included(model) model.class_eval do cattr_accessor :field_with_tags @@ -23,7 +25,7 @@ module Diaspora end def tag_strings - regex = /(?:^|\s)#(\w+)/ + regex = /(?:^|\s)#(#{VALID_TAG_BODY})/ matches = self.send(self.class.field_with_tags).scan(regex).map do |match| match.last end @@ -36,7 +38,7 @@ module Diaspora def format_tags(text, opts={}) return text if opts[:plain_text] - regex = /(^|\s)#(\w+)/ + regex = /(^|\s)#(#{VALID_TAG_BODY})/ form_message = text.gsub(regex) do |matched_string| "#{$~[1]}##{$~[2]}" end