Skip to content

Commit d79b44a

Browse files
committed
Field mask validation
1 parent b4d40fc commit d79b44a

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

php/ext/google/protobuf/php-upb.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,14 +2526,14 @@ static void jsonenc_fieldpath(jsonenc* e, upb_StringView path) {
25262526
while (ptr < end) {
25272527
char ch = *ptr;
25282528

2529-
if (ch >= 'A' && ch <= 'Z') {
2530-
jsonenc_err(e, "Field mask element may not have upper-case letter.");
2531-
} else if (ch == '_') {
2532-
if (ptr == end - 1 || *(ptr + 1) < 'a' || *(ptr + 1) > 'z') {
2533-
jsonenc_err(e, "Underscore must be followed by a lowercase letter.");
2534-
}
2535-
ch = *++ptr - 32;
2536-
}
2529+
// if (ch >= 'A' && ch <= 'Z') {
2530+
// jsonenc_err(e, "Field mask element may not have upper-case letter.");
2531+
// } else if (ch == '_') {
2532+
// if (ptr == end - 1 || *(ptr + 1) < 'a' || *(ptr + 1) > 'z') {
2533+
// jsonenc_err(e, "Underscore must be followed by a lowercase letter.");
2534+
// }
2535+
// ch = *++ptr - 32;
2536+
// }
25372537

25382538
jsonenc_putbytes(e, &ch, 1);
25392539
ptr++;

php/tests/field_mask_test.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
require_once (dirname(__DIR__) . '/vendor/autoload.php');
4+
require_once (__DIR__ . '/test_util.php');
5+
6+
use Google\Protobuf\FieldMask;
7+
8+
$m1 = new FieldMask();
9+
$m2 = new FieldMask();
10+
11+
$m1->setPaths(['phoneNumber', 'emailAddress']);
12+
13+
$m2->mergeFromJsonString($m1->serializeToJsonString());
14+
15+
var_dump($m2->getPaths());
16+
var_dump($m2->serializeToJsonString());

0 commit comments

Comments
 (0)