Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

Commit

Permalink
Fix sanitization of pantographs
Browse files Browse the repository at this point in the history
  • Loading branch information
joegatt committed Sep 9, 2013
1 parent 8eda793 commit 6eefb80
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/concerns/pantographable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def sanitize(text)
.gsub(/\[\{/, '(')
.gsub(/\]\}/, ')')
.downcase
.gsub(/[^#{ self.alphabet }]/, '')
.gsub(/[^#{ Settings.pantography.alphabet_escaped }]/, '')
end

def authenticated_twitter_client
Expand Down
3 changes: 3 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ defaults: &defaults
page_size: 30
pantography:
alphabet: 0123456789.,;:_@!?/#()%'-+= abcdefghijklmnopqrstuvwxyz
alphabet_escaped: 0123456789.,;:_@!?/#()%'\-+= abcdefghijklmnopqrstuvwxyz
twitter_user_id: 394339242
books:
google_books:
Expand Down Expand Up @@ -172,6 +173,7 @@ development:
errors: ['', 'UNKNOWN', 'BAD_DATA_FORMAT', 'PERMISSION_DENIED', 'INTERNAL_ERROR', 'DATA_REQUIRED', 'LIMIT_REACHED', 'QUOTA_REACHED', 'INVALID_AUTH', 'AUTH_EXPIRED', 'DATA_CONFLICT', 'ENML_VALIDATION', 'SHARD_UNAVAILABLE', 'LEN_TOO_SHORT', 'LEN_TOO_LONG', 'TOO_FEW', 'TOO_MANY', 'UNSUPPORTED_OPERATION']
pantography:
alphabet: 0123456789.,;:_@!?/#()%'-+= abcdefghijklmnopqrstuvwxyz
alphabet_escaped: 0123456789.,;:_@!?/#()%'\-+= abcdefghijklmnopqrstuvwxyz
twitter_user_id: 237443494

test:
Expand Down Expand Up @@ -202,6 +204,7 @@ test:
page_size: 30
pantography:
alphabet: 0123456789.,;:_@!?/#()%'-+= abcdefghijklmnopqrstuvwxyz
alphabet_escaped: 0123456789.,;:_@!?/#()%'\-+= abcdefghijklmnopqrstuvwxyz
twitter_user_id: 237443494


Expand Down
4 changes: 4 additions & 0 deletions spec/models/pantograph_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
specify { Pantograph.calculate_after('.zz').should eq(',00') }
end

describe '.sanitize' do
specify { Pantograph.sanitize(Settings.pantography.alphabet_escaped).should eq(Pantograph.alphabet) }
end

# describe '.publish_next' do
# Pantograph.publish_next.should == ''
# end
Expand Down

0 comments on commit 6eefb80

Please sign in to comment.