Skip to content

Commit

Permalink
fix escape double quote in msgid issue
Browse files Browse the repository at this point in the history
in method push_buffer, gsub will NOT modify the original string object, use gsub! instead
  • Loading branch information
chaomao authored and mao chao committed Jul 16, 2023
1 parent 57b3f1d commit bb39bd4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/po_to_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def assign_trans

def push_buffer(value, key = nil)
value = $1 if value =~ /^"(.*)"/
value.gsub(/\\"/, "\"")
value.gsub!(/\\"/, "\"")

if key.nil?
buffer[lastkey] = [
Expand Down
3 changes: 3 additions & 0 deletions spec/fixtures/test.po
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,6 @@ msgstr "Du solltest '\\' als '\\\\' escapen."

msgid "Umläüte"
msgstr "Umlaute"

msgid "contains double quote, say \"Hello\""
msgstr "contains double quote, say \"Hello\""
5 changes: 5 additions & 0 deletions spec/po_to_json_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
eq(["Auto"])
)
end
it "should not espace double quote in msgid" do
expect(
subject["contains double quote, say \"Hello\""]
).to be_truthy
end
end

describe "generate jed compatible" do
Expand Down

0 comments on commit bb39bd4

Please sign in to comment.