@@ -390,7 +390,7 @@ private void serializeLength(StringBuffer buffer, int length) {
390
390
buffer[buffer.length] = 's';
391
391
buffer[buffer.length] = String.fromCharCode (baseChar - 1);
392
392
} else {
393
- var normal = /^[\u0000-\u00ff ]*$/.test(s);
393
+ var normal = /^[\r\n\t\u0020-\u007e ]*$/.test(s);
394
394
if (normal) {
395
395
buffer[buffer.length] = 's';
396
396
} else {
@@ -459,6 +459,7 @@ private void serializeString(StringBuffer buffer, String s) throws UnsupportedEn
459
459
while (index < length) {
460
460
var c1 = str.charCodeAt (index++);
461
461
var l1 = c1 - baseChar;
462
+ if (l1 < 0) return;
462
463
var fieldName = str.substring (index, index + l1);
463
464
index += l1;
464
465
var c2 = str.charAt (index++);
@@ -476,6 +477,7 @@ private void serializeString(StringBuffer buffer, String s) throws UnsupportedEn
476
477
if (l2 == -2) {
477
478
var c4 = str.charCodeAt(index++);
478
479
var l3 = c4 - baseChar;
480
+ if (l3 < 0) return;
479
481
l2 = parseInt(str.substring(index, index + l3));
480
482
if (l2 > 0x4000) { // 16 * 1024
481
483
throw new RuntimeException("Array size reaches the limit of Java2Script Simple RPC!");
@@ -502,7 +504,9 @@ private void serializeString(StringBuffer buffer, String s) throws UnsupportedEn
502
504
} else if (l3 == -2) {
503
505
var c6 = str.charCodeAt (index++);
504
506
var l4 = c6 - baseChar;
507
+ if (l4 < 0) return;
505
508
var l5 = parseInt (str.substring( index, index + l4));
509
+ if (l5 < 0) return;
506
510
index += l4;
507
511
s = str.substring (index, index + l5);
508
512
index += l5;
@@ -538,7 +542,9 @@ private void serializeString(StringBuffer buffer, String s) throws UnsupportedEn
538
542
} else if (l2 == -2) {
539
543
var c4 = str.charCodeAt(index++);
540
544
var l3 = c4 - baseChar;
545
+ if (l3 < 0) return;
541
546
var l4 = parseInt(str.substring(index, index + l3));
547
+ if (l4 < 0) return;
542
548
index += l3;
543
549
s = str.substring(index, index + l4);
544
550
index += l4;
@@ -599,6 +605,7 @@ public void deserialize(String str) {
599
605
while (index < length ) {
600
606
char c1 = str .charAt (index ++);
601
607
int l1 = c1 - baseChar ;
608
+ if (l1 < 0 ) return ;
602
609
String fieldName = str .substring (index , index + l1 );
603
610
index += l1 ;
604
611
char c2 = str .charAt (index ++);
@@ -617,6 +624,7 @@ public void deserialize(String str) {
617
624
if (l2 == -2 ) {
618
625
char c4 = str .charAt (index ++);
619
626
int l3 = c4 - baseChar ;
627
+ if (l3 < 0 ) return ;
620
628
l2 = Integer .parseInt (str .substring (index , index + l3 ));
621
629
if (l2 > 0x4000 ) { // 16 * 1024
622
630
/*
@@ -645,7 +653,9 @@ public void deserialize(String str) {
645
653
} else if (l3 == -2 ) {
646
654
char c6 = str .charAt (index ++);
647
655
int l4 = c6 - baseChar ;
656
+ if (l4 < 0 ) return ;
648
657
int l5 = Integer .parseInt (str .substring (index , index + l4 ));
658
+ if (l5 < 0 ) return ;
649
659
index += l4 ;
650
660
ss [i ] = str .substring (index , index + l5 );
651
661
index += l5 ;
@@ -761,7 +771,9 @@ public void deserialize(String str) {
761
771
} else if (l2 == -2 ) {
762
772
char c4 = str .charAt (index ++);
763
773
int l3 = c4 - baseChar ;
774
+ if (l3 < 0 ) return ;
764
775
int l4 = Integer .parseInt (str .substring (index , index + l3 ));
776
+ if (l4 < 0 ) return ;
765
777
index += l3 ;
766
778
s = str .substring (index , index + l4 );
767
779
index += l4 ;
0 commit comments