Skip to content

Commit

Permalink
protoprint: fix bug in escaping double-quote characters (#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
japersik committed Oct 31, 2023
1 parent 3839451 commit e429ee6
Show file tree
Hide file tree
Showing 33 changed files with 747 additions and 745 deletions.
28 changes: 14 additions & 14 deletions desc/protoparse/test-source-info.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ desc_test_complex.proto:31:30

> message_type[1] > extension_range:
desc_test_complex.proto:33:9
desc_test_complex.proto:33:81
desc_test_complex.proto:33:91


> message_type[1] > extension_range[1]:
Expand Down Expand Up @@ -1607,42 +1607,42 @@ desc_test_complex.proto:33:61

> message_type[1] > extension_range[1] > options:
desc_test_complex.proto:33:62
desc_test_complex.proto:33:80
desc_test_complex.proto:33:90


> message_type[1] > extension_range[1] > options > (foo.bar.label):
desc_test_complex.proto:33:63
desc_test_complex.proto:33:79
desc_test_complex.proto:33:89


> message_type[1] > extension_range[2] > options:
desc_test_complex.proto:33:62
desc_test_complex.proto:33:80
desc_test_complex.proto:33:90


> message_type[1] > extension_range[2] > options > (foo.bar.label):
desc_test_complex.proto:33:63
desc_test_complex.proto:33:79
desc_test_complex.proto:33:89


> message_type[1] > extension_range[3] > options:
desc_test_complex.proto:33:62
desc_test_complex.proto:33:80
desc_test_complex.proto:33:90


> message_type[1] > extension_range[3] > options > (foo.bar.label):
desc_test_complex.proto:33:63
desc_test_complex.proto:33:79
desc_test_complex.proto:33:89


> message_type[1] > extension_range[4] > options:
desc_test_complex.proto:33:62
desc_test_complex.proto:33:80
desc_test_complex.proto:33:90


> message_type[1] > extension_range[4] > options > (foo.bar.label):
desc_test_complex.proto:33:63
desc_test_complex.proto:33:79
desc_test_complex.proto:33:89


> message_type[1] > nested_type[1]:
Expand Down Expand Up @@ -5426,17 +5426,17 @@ desc_test_complex.proto:275:99

> message_type[9] > field[0] > options > (foo.bar.string):
desc_test_complex.proto:276:17
desc_test_complex.proto:276:36
desc_test_complex.proto:276:78


> message_type[9] > field[0] > options > (foo.bar.bytes):
desc_test_complex.proto:276:38
desc_test_complex.proto:276:55
desc_test_complex.proto:276:80
desc_test_complex.proto:276:139


> message_type[9] > field[0] > options > (foo.bar.bool):
desc_test_complex.proto:276:57
desc_test_complex.proto:276:70
desc_test_complex.proto:276:141
desc_test_complex.proto:276:154


> message_type[9] > field[0] > options > (foo.bar.float):
Expand Down
4 changes: 2 additions & 2 deletions desc/protoprint/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -2015,7 +2015,7 @@ func quotedBytes(s string) string {
case '\t':
b.WriteString("\\t")
case '"':
b.WriteString("\\")
b.WriteString("\\\"")
case '\\':
b.WriteString("\\\\")
default:
Expand Down Expand Up @@ -2061,7 +2061,7 @@ func quotedString(s string) string {
case '\t':
b.WriteString("\\t")
case '"':
b.WriteString("\\")
b.WriteString("\\\"")
case '\\':
b.WriteString("\\\\")
default:
Expand Down
6 changes: 3 additions & 3 deletions desc/protoprint/testfiles/desc_test_complex-compact.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ message Test {
map<string, int32> m = 5;
optional bytes b = 6 [default = "\000\001\002\003\004\005\006\007fubar!"];
extensions 100 to 200;
extensions 249, 300 to 350, 500 to 550, 20000 to max [(label) = "jazz"];
extensions 249, 300 to 350, 500 to 550, 20000 to max [(label) = "jazz \"hands\""];
message Nested {
extend google.protobuf.MessageOptions {
optional int32 fooblez = 20003;
Expand Down Expand Up @@ -248,8 +248,8 @@ message KeywordCollisionOptions {
(public) = true,
(weak) = true,
(package) = true,
(string) = "string",
(bytes) = "bytes",
(string) = "string蝥\U00107F6D\007\010\014\n\r\t\013\\\"'?B",
(bytes) = "bytes\350\235\245\364\207\275\255\007\010\014\n\r\t\013\\\"'?B",
(bool) = true,
(float) = 3.140000,
(double) = 3.141590,
Expand Down
6 changes: 3 additions & 3 deletions desc/protoprint/testfiles/desc_test_complex-custom-sort.proto
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ message Validator {
}

message Test {
extensions 20000 to max, 500 to 550, 300 to 350, 249 [(label) = "jazz"];
extensions 20000 to max, 500 to 550, 300 to 350, 249 [(label) = "jazz \"hands\""];

extensions 100 to 200;

Expand Down Expand Up @@ -385,7 +385,7 @@ message KeywordCollisionOptions {
(true) = 111,
(to) = true,
(syntax) = true,
(string) = "string",
(string) = "string蝥\U00107F6D\007\010\014\n\r\t\013\\\"'?B",
(sint64) = -64,
(sint32) = -32,
(sfixed64) = -6464,
Expand All @@ -412,7 +412,7 @@ message KeywordCollisionOptions {
(enum) = true,
(double) = 3.141590,
(default) = 222,
(bytes) = "bytes",
(bytes) = "bytes\350\235\245\364\207\275\255\007\010\014\n\r\t\013\\\"'?B",
(bool) = true
];
}
Expand Down
6 changes: 3 additions & 3 deletions desc/protoprint/testfiles/desc_test_complex-default.proto
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ message Test {

extensions 100 to 200;

extensions 249, 300 to 350, 500 to 550, 20000 to max [(label) = "jazz"];
extensions 249, 300 to 350, 500 to 550, 20000 to max [(label) = "jazz \"hands\""];

message Nested {
extend google.protobuf.MessageOptions {
Expand Down Expand Up @@ -406,8 +406,8 @@ message KeywordCollisionOptions {
(public) = true,
(weak) = true,
(package) = true,
(string) = "string",
(bytes) = "bytes",
(string) = "string蝥\U00107F6D\007\010\014\n\r\t\013\\\"'?B",
(bytes) = "bytes\350\235\245\364\207\275\255\007\010\014\n\r\t\013\\\"'?B",
(bool) = true,
(float) = 3.140000,
(double) = 3.141590,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ message Test {

extensions 100 to 200;

extensions 249, 300 to 350, 500 to 550, 20000 to max [(label) = "jazz"];
extensions 249, 300 to 350, 500 to 550, 20000 to max [(label) = "jazz \"hands\""];

message Nested {
extend google.protobuf.MessageOptions {
Expand Down Expand Up @@ -406,8 +406,8 @@ message KeywordCollisionOptions {
(public) = true,
(weak) = true,
(package) = true,
(string) = "string",
(bytes) = "bytes",
(string) = "string蝥\U00107F6D\007\010\014\n\r\t\013\\\"'?B",
(bytes) = "bytes\350\235\245\364\207\275\255\007\010\014\n\r\t\013\\\"'?B",
(bool) = true,
(float) = 3.140000,
(double) = 3.141590,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ message Test {

extensions 100 to 200;

extensions 249, 300 to 350, 500 to 550, 20000 to max [(label) = "jazz"];
extensions 249, 300 to 350, 500 to 550, 20000 to max [(label) = "jazz \"hands\""];

message Nested {
extend google.protobuf.MessageOptions {
Expand Down Expand Up @@ -406,8 +406,8 @@ message KeywordCollisionOptions {
(public) = true,
(weak) = true,
(package) = true,
(string) = "string",
(bytes) = "bytes",
(string) = "string蝥\U00107F6D\007\010\014\n\r\t\013\\\"'?B",
(bytes) = "bytes\350\235\245\364\207\275\255\007\010\014\n\r\t\013\\\"'?B",
(bool) = true,
(float) = 3.140000,
(double) = 3.141590,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ message Test {

extensions 100 to 200;

extensions 249, 300 to 350, 500 to 550, 20000 to max [(label) = "jazz"];
extensions 249, 300 to 350, 500 to 550, 20000 to max [(label) = "jazz \"hands\""];

message Nested {
extend google.protobuf.MessageOptions {
Expand Down Expand Up @@ -404,8 +404,8 @@ message KeywordCollisionOptions {
(public) = true,
(weak) = true,
(package) = true,
(string) = "string",
(bytes) = "bytes",
(string) = "string蝥\U00107F6D\007\010\014\n\r\t\013\\\"'?B",
(bytes) = "bytes\350\235\245\364\207\275\255\007\010\014\n\r\t\013\\\"'?B",
(bool) = true,
(float) = 3.140000,
(double) = 3.141590,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ message IsAuthorizedReq {
message KeywordCollisionOptions {
optional uint64 id = 1 [
(bool) = true,
(bytes) = "bytes",
(bytes) = "bytes\350\235\245\364\207\275\255\007\010\014\n\r\t\013\\\"'?B",
(default) = 222,
(double) = 3.141590,
(enum) = true,
Expand All @@ -93,7 +93,7 @@ message KeywordCollisionOptions {
(sfixed64) = -6464,
(sint32) = -32,
(sint64) = -64,
(string) = "string",
(string) = "string蝥\U00107F6D\007\010\014\n\r\t\013\\\"'?B",
(syntax) = true,
(to) = true,
(true) = 111,
Expand Down Expand Up @@ -332,7 +332,7 @@ message Test {

extensions 100 to 200;

extensions 249, 300 to 350, 500 to 550, 20000 to max [(label) = "jazz"];
extensions 249, 300 to 350, 500 to 550, 20000 to max [(label) = "jazz \"hands\""];
}

message Validator {
Expand Down
6 changes: 3 additions & 3 deletions desc/protoprint/testfiles/desc_test_complex-sorted.proto
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ message IsAuthorizedReq {
message KeywordCollisionOptions {
optional uint64 id = 1 [
(bool) = true,
(bytes) = "bytes",
(bytes) = "bytes\350\235\245\364\207\275\255\007\010\014\n\r\t\013\\\"'?B",
(default) = 222,
(double) = 3.141590,
(enum) = true,
Expand All @@ -93,7 +93,7 @@ message KeywordCollisionOptions {
(sfixed64) = -6464,
(sint32) = -32,
(sint64) = -64,
(string) = "string",
(string) = "string蝥\U00107F6D\007\010\014\n\r\t\013\\\"'?B",
(syntax) = true,
(to) = true,
(true) = 111,
Expand Down Expand Up @@ -330,7 +330,7 @@ message Test {

extensions 100 to 200;

extensions 249, 300 to 350, 500 to 550, 20000 to max [(label) = "jazz"];
extensions 249, 300 to 350, 500 to 550, 20000 to max [(label) = "jazz \"hands\""];
}

message Validator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ message Test {

extensions 100 to 200;

extensions 249, 300 to 350, 500 to 550, 20000 to max [(label) = "jazz"];
extensions 249, 300 to 350, 500 to 550, 20000 to max [(label) = "jazz \"hands\""];

message Nested {
extend google.protobuf.MessageOptions {
Expand Down Expand Up @@ -409,8 +409,8 @@ message KeywordCollisionOptions {
(public) = true,
(weak) = true,
(package) = true,
(string) = "string",
(bytes) = "bytes",
(string) = "string蝥\U00107F6D\007\010\014\n\r\t\013\\\"'?B",
(bytes) = "bytes\350\235\245\364\207\275\255\007\010\014\n\r\t\013\\\"'?B",
(bool) = true,
(float) = 3.140000,
(double) = 3.141590,
Expand Down
2 changes: 1 addition & 1 deletion internal/testprotos/desc_test1.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/testprotos/desc_test2.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e429ee6

Please sign in to comment.