mirror of
https://github.com/lingble/chatwoot.git
synced 2025-10-29 18:22:53 +00:00
fix: properly escape GraphQL strings in Linear mutations
This commit is contained in:
@@ -2,8 +2,9 @@ module Linear::Mutations
|
||||
def self.graphql_value(value)
|
||||
case value
|
||||
when String
|
||||
# Strings must be enclosed in double quotes
|
||||
"\"#{value.gsub("\n", '\\n')}\""
|
||||
# Strings must be enclosed in double quotes and properly escaped
|
||||
escaped = value.gsub('\\', '\\\\').gsub('"', '\\"').gsub("\n", '\\n').gsub("\r", '\\r').gsub("\t", '\\t')
|
||||
"\"#{escaped}\""
|
||||
when Array
|
||||
# Arrays need to be recursively converted
|
||||
"[#{value.map { |v| graphql_value(v) }.join(', ')}]"
|
||||
|
||||
Reference in New Issue
Block a user