Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/sonic/channels/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def normalize(value)
end

def sanitize(value)
value.gsub('"', '\\"').gsub(/[\r\n]+/, ' ')
value.gsub('"', '\\"').gsub(/[\r\n]+/, '\\n').gsub(/\\/, '\\\\')
end

def quote(value)
Expand Down
4 changes: 2 additions & 2 deletions lib/sonic/channels/ingest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ module Sonic
module Channels
class Ingest < Base
def push(collection, bucket, object, text, lang = nil)
arr = [collection, bucket, object, quote(text)]
arr = [collection, bucket, object, normalize(text)]
arr << "LANG(#{lang})" if lang

execute('PUSH', *arr)
end

def pop(collection, bucket, object, text)
execute('POP', collection, bucket, object, quote(text))
execute('POP', collection, bucket, object, normalize(text))
end

def count(collection, bucket = nil, object = nil)
Expand Down
4 changes: 2 additions & 2 deletions lib/sonic/channels/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Sonic
module Channels
class Search < Base
def query(collection, bucket, terms, limit = nil, offset = nil, lang = nil) # rubocop:disable Metrics/ParameterLists, Metrics/LineLength
arr = [collection, bucket, quote(terms)]
arr = [collection, bucket, normalize(terms)]
arr << "LIMIT(#{limit})" if limit
arr << "OFFSET(#{offset})" if offset
arr << "LANG(#{lang})" if lang
Expand All @@ -13,7 +13,7 @@ def query(collection, bucket, terms, limit = nil, offset = nil, lang = nil) # ru
end

def suggest(collection, bucket, word, limit = nil)
arr = [collection, bucket, quote(word)]
arr = [collection, bucket, normalize(word)]
arr << "LIMIT(#{limit})" if limit

execute('SUGGEST', *arr) do
Expand Down