Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Fix string literal character escaping in Ruby generator #2861

Merged
merged 2 commits into from
Jun 28, 2019
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import com.google.api.codegen.config.FieldConfig;
import com.google.api.codegen.transformer.ModelTypeNameConverter;
import com.google.api.codegen.util.EscaperFactory;
import com.google.api.codegen.util.NamePath;
import com.google.api.codegen.util.TypeName;
import com.google.api.codegen.util.TypeNameConverter;
Expand Down Expand Up @@ -162,7 +163,7 @@ public String renderPrimitiveValue(TypeRef type, String value) {
return value.toLowerCase();
case TYPE_STRING:
case TYPE_BYTES:
return "\"" + value + "\"";
return "\"" + EscaperFactory.getDoubleQuoteEscaper().escape(value) + "\"";
default:
// Types that do not need to be modified (e.g. TYPE_INT32) are handled
// here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5707,8 +5707,7 @@ def sample_get_big_book shelf
# Instantiate a client
library_client = Library::Library.new version: :v1

# shelf = "Novel\"`
# "
# shelf = "Novel\\\"`\b\t\n\r"
formatted_name = library_client.class.book_path(shelf, "War and Peace")

# Make the long-running operation request
Expand Down Expand Up @@ -5746,8 +5745,7 @@ require "optparse"

if $PROGRAM_NAME == __FILE__

shelf = "Novel\"`
"
shelf = "Novel\\\"`\b\t\n\r"

ARGV.options do |opts|
opts.on("--shelf=val") { |val| shelf = val }
Expand Down Expand Up @@ -6721,8 +6719,7 @@ def sample_get_big_book shelf
# Instantiate a client
library_client = Library::Library.new version: :v1

# shelf = "Novel\"`
# "
# shelf = "Novel\\\"`\b\t\n\r"
formatted_name = library_client.class.book_path(shelf, "War and Peace")

# Make the long-running operation request
Expand Down Expand Up @@ -6760,8 +6757,7 @@ require "optparse"

if $PROGRAM_NAME == __FILE__

shelf = "Novel\"`
"
shelf = "Novel\\\"`\b\t\n\r"

ARGV.options do |opts|
opts.on("--shelf=val") { |val| shelf = val }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5693,8 +5693,7 @@ def sample_get_big_book shelf
# Instantiate a client
library_client = Library::Library.new version: :v1

# shelf = "Novel\"`
# "
# shelf = "Novel\\\"`\b\t\n\r"
formatted_name = library_client.class.book_path("[BOOK_SHELF]", "[BOOK]")

# Make the long-running operation request
Expand Down Expand Up @@ -5732,8 +5731,7 @@ require "optparse"

if $PROGRAM_NAME == __FILE__

shelf = "Novel\"`
"
shelf = "Novel\\\"`\b\t\n\r"

ARGV.options do |opts|
opts.on("--shelf=val") { |val| shelf = val }
Expand Down Expand Up @@ -6707,8 +6705,7 @@ def sample_get_big_book shelf
# Instantiate a client
library_client = Library::Library.new version: :v1

# shelf = "Novel\"`
# "
# shelf = "Novel\\\"`\b\t\n\r"
formatted_name = library_client.class.book_path("[BOOK_SHELF]", "[BOOK]")

# Make the long-running operation request
Expand Down Expand Up @@ -6746,8 +6743,7 @@ require "optparse"

if $PROGRAM_NAME == __FILE__

shelf = "Novel\"`
"
shelf = "Novel\\\"`\b\t\n\r"

ARGV.options do |opts|
opts.on("--shelf=val") { |val| shelf = val }
Expand Down