fix: properly escape GraphQL strings in Linear mutations

This commit is contained in:
Muhsin
2025-10-07 17:03:35 +05:30
parent 829142c808
commit 58a06dc455

View File

@@ -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(', ')}]"