File tree Expand file tree Collapse file tree
java/test/org/openqa/selenium/json Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -293,14 +293,19 @@ void shouldBeAbleToReadNonWellFormedDataLongerThanReadBuffer() {
293293
294294 @ Test
295295 void shouldReadU_FFFF_AsALiteralCharacterAndNotEndOfInput () {
296- // U+FFFF is a valid (non-)character; historically it collided with an in-band EOF sentinel
297- // and was mis-reported as an unterminated string.
298- try (JsonInput input = newInput ("\" ab\" " )) {
299- assertThat (input .nextString ()).isEqualTo ("ab" );
296+ // U+FFFF is a valid Unicode code unit that historically collided with the in-band EOF
297+ // sentinel and was mis-reported as an unterminated string. Build the strings from
298+ // char values rather than embedding literal U+FFFF so the test is independent of the
299+ // source file's byte encoding.
300+ char nonChar = (char ) 0xFFFF ;
301+ String literalPayload = "a" + nonChar + "b" ;
302+
303+ try (JsonInput input = newInput ("\" " + literalPayload + "\" " )) {
304+ assertThat (input .nextString ()).isEqualTo (literalPayload );
300305 }
301306
302307 try (JsonInput input = newInput ("\" \\ uFFFF\" " )) {
303- assertThat (input .nextString ()).isEqualTo ("" );
308+ assertThat (input .nextString ()).isEqualTo (String . valueOf ( nonChar ) );
304309 }
305310 }
306311
You can’t perform that action at this time.
0 commit comments