aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfrancis <francis>2008-12-04 19:23:07 +0000
committerfrancis <francis>2008-12-04 19:23:07 +0000
commit277f8bece2d3260aaa229ba27506f0039a19d356 (patch)
tree4e75ed3453a34091f39800099ad508e860302da2
parentd8ee95d7f04f83b29d0ccc02a0e6a9e00fce5717 (diff)
Let censor rules to work on nil values (can happen with filenames)
-rw-r--r--app/models/censor_rule.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/censor_rule.rb b/app/models/censor_rule.rb
index a0606c4f8..b064a13f3 100644
--- a/app/models/censor_rule.rb
+++ b/app/models/censor_rule.rb
@@ -21,7 +21,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: censor_rule.rb,v 1.2 2008-10-28 13:04:20 francis Exp $
+# $Id: censor_rule.rb,v 1.3 2008-12-04 19:23:07 francis Exp $
class CensorRule < ActiveRecord::Base
belongs_to :info_request
@@ -29,10 +29,16 @@ class CensorRule < ActiveRecord::Base
belongs_to :public_body
def apply_to_text(text)
+ if text.nil?
+ return nil?
+ end
text.gsub!(self.text, self.replacement)
return text
end
def apply_to_binary(binary)
+ if binary.nil?
+ return nil?
+ end
replacement = self.text.gsub(/./, 'x')
binary.gsub!(self.text, replacement)
return binary