Skip to content

Commit

Permalink
Auto escape " and \ characters
Browse files Browse the repository at this point in the history
  • Loading branch information
MineBartekSA committed Sep 12, 2022
1 parent 7ee1929 commit f65c087
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion utils.ru
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def prettyJson(args)
end

def literalNewline(args)
print args[0].gsub(/\r{0,1}\n/, "\\n")
print args[0].gsub(/\r{0,1}\n/, "\\n").gsub(/\\[^n]|"/) { |s| (s.size == 1 ? "\\" : "\\\\") + s }
end

def handleJson(args)
Expand Down

0 comments on commit f65c087

Please sign in to comment.