Skip to content

Commit 87bce21

Browse files
authored
Merge branch 'trunk' into sm_firefox_linux
2 parents 70d00d1 + d037099 commit 87bce21

6 files changed

Lines changed: 81 additions & 152 deletions

File tree

common/repositories.bzl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ def pin_browsers():
1111

1212
http_archive(
1313
name = "linux_firefox",
14-
url = "https://ftp.mozilla.org/pub/firefox/releases/152.0.3/linux-x86_64/en-US/firefox-152.0.3.tar.xz",
15-
sha256 = "8bdb7a9138f40a1bc9191e9803d3cb5e1c3086e815821c7f42bcda7b8b98144b",
14+
url = "https://ftp.mozilla.org/pub/firefox/releases/152.0.4/linux-x86_64/en-US/firefox-152.0.4.tar.xz",
15+
sha256 = "cfbe0a66269f220c69809210eda55fee72f4798427e78181b7d0da14df44882f",
1616
build_file_content = """
1717
load("@aspect_rules_js//js:defs.bzl", "js_library")
1818
package(default_visibility = ["//visibility:public"])
@@ -33,8 +33,8 @@ js_library(
3333

3434
dmg_archive(
3535
name = "mac_firefox",
36-
url = "https://ftp.mozilla.org/pub/firefox/releases/152.0.3/mac/en-US/Firefox%20152.0.3.dmg",
37-
sha256 = "5341a832935516be4f164d15021fb5a872668d6ebeddcdf35ae09ca599e717f0",
36+
url = "https://ftp.mozilla.org/pub/firefox/releases/152.0.4/mac/en-US/Firefox%20152.0.4.dmg",
37+
sha256 = "b7391215608c8f0171c29200bb7add9328d186a60c10386b67acfa5f757a42b8",
3838
build_file_content = """
3939
load("@aspect_rules_js//js:defs.bzl", "js_library")
4040
package(default_visibility = ["//visibility:public"])
@@ -50,8 +50,8 @@ js_library(
5050

5151
http_archive(
5252
name = "linux_beta_firefox",
53-
url = "https://ftp.mozilla.org/pub/firefox/releases/153.0b5/linux-x86_64/en-US/firefox-153.0b5.tar.xz",
54-
sha256 = "06d7dbc92afc6fbf83b8f830e5fc8d2293e18634d9a7da5cdf8cdce19f6edc8b",
53+
url = "https://ftp.mozilla.org/pub/firefox/releases/153.0b7/linux-x86_64/en-US/firefox-153.0b7.tar.xz",
54+
sha256 = "8da26e77fec0a18c4d110c1ae9cbef63f385174d10202bce7c56b2d724d297b2",
5555
build_file_content = """
5656
load("@aspect_rules_js//js:defs.bzl", "js_library")
5757
package(default_visibility = ["//visibility:public"])
@@ -72,8 +72,8 @@ js_library(
7272

7373
dmg_archive(
7474
name = "mac_beta_firefox",
75-
url = "https://ftp.mozilla.org/pub/firefox/releases/153.0b5/mac/en-US/Firefox%20153.0b5.dmg",
76-
sha256 = "21623ec2066a747498776c39392769260c3e7e0e474d8e5c1c9ac46a950823c7",
75+
url = "https://ftp.mozilla.org/pub/firefox/releases/153.0b7/mac/en-US/Firefox%20153.0b7.dmg",
76+
sha256 = "9ce38b03da60d246a57f95ff7efd6cf86a29133ece547dee78f337f5084dccdd",
7777
build_file_content = """
7878
load("@aspect_rules_js//js:defs.bzl", "js_library")
7979
package(default_visibility = ["//visibility:public"])

dotnet/test/support/Events/EventFiringWebDriverTests.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -219,19 +219,18 @@ public void ShouldUnwrapElementArgsWhenCallingScripts()
219219
public void ShouldBeAbleToWrapSubclassesOfSomethingImplementingTheWebDriverInterface()
220220
{
221221
// We should get this far
222-
EventFiringWebDriver testDriver = new EventFiringWebDriver(new ChildDriver());
222+
EventFiringWebDriver testDriver = new EventFiringWebDriver(mockDriver.Object);
223223
}
224224

225225
[Test]
226226
public void ShouldBeAbleToAccessWrappedInstanceFromEventCalls()
227227
{
228-
var stubDriver = new StubDriver();
229-
EventFiringWebDriver testDriver = new EventFiringWebDriver(stubDriver);
230-
StubDriver wrapped = ((IWrapsDriver)testDriver).WrappedDriver as StubDriver;
231-
Assert.That(wrapped, Is.EqualTo(stubDriver));
228+
EventFiringWebDriver testDriver = new EventFiringWebDriver(mockDriver.Object);
229+
IWebDriver wrapped = ((IWrapsDriver)testDriver).WrappedDriver;
230+
Assert.That(wrapped, Is.SameAs(mockDriver.Object));
232231
testDriver.Navigating += new EventHandler<WebDriverNavigationEventArgs>((sender, e) =>
233232
{
234-
Assert.That(stubDriver, Is.EqualTo(e.Driver));
233+
Assert.That(e.Driver, Is.SameAs(mockDriver.Object));
235234
});
236235

237236
testDriver.Url = "http://example.org";
@@ -293,8 +292,4 @@ public void ShouldFireFindEventsInShadowRoot()
293292
public interface IExecutingDriver : IWebDriver, IJavaScriptExecutor
294293
{
295294
}
296-
297-
public class ChildDriver : StubDriver
298-
{
299-
}
300295
}

dotnet/test/webdriver/Infrastructure/StubDriver.cs

Lines changed: 0 additions & 112 deletions
This file was deleted.

java/src/org/openqa/selenium/json/Input.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@
2929
* read characters in the input buffer.
3030
*/
3131
class Input {
32-
/** end-of-file indicator (0xFFFD) */
33-
public static final char EOF = (char) -1; // NOTE: Produces Unicode replacement character (0xFFFD)
32+
/**
33+
* End-of-input sentinel returned by {@link #peek()} and {@link #read()}.
34+
*
35+
* <p>Value {@code -1} mirrors {@link java.io.Reader#read()} and — unlike a {@code char} sentinel
36+
* — cannot collide with any valid UTF-16 code unit (including U+FFFF).
37+
*/
38+
public static final int EOF = -1;
3439

3540
/** the number of chars to buffer */
3641
private static final int BUFFER_SIZE = 4096;
@@ -64,18 +69,20 @@ public Input(Reader source) {
6469
/**
6570
* Extract the next character from the input without consuming it.
6671
*
67-
* @return the next input character; {@link #EOF} if input is exhausted
72+
* @return the next input character as an unsigned UTF-16 code unit (0-65535); {@link #EOF} if
73+
* input is exhausted
6874
*/
69-
public char peek() {
75+
public int peek() {
7076
return fill() ? buffer[position + 1] : EOF;
7177
}
7278

7379
/**
7480
* Read and consume the next character from the input.
7581
*
76-
* @return the next input character; {@link #EOF} if input is exhausted
82+
* @return the next input character as an unsigned UTF-16 code unit (0-65535); {@link #EOF} if
83+
* input is exhausted
7784
*/
78-
public char read() {
85+
public int read() {
7986
return fill() ? buffer[++position] : EOF;
8087
}
8188

java/src/org/openqa/selenium/json/JsonInput.java

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ public JsonType peek() {
165165
return JsonType.END;
166166

167167
default:
168-
char c = input.read();
169-
throw new JsonException("Unable to determine type from: " + c + ". " + input);
168+
int c = input.read();
169+
throw new JsonException("Unable to determine type from: " + (char) c + ". " + input);
170170
}
171171
}
172172

@@ -194,10 +194,10 @@ public String nextName() {
194194

195195
String name = readString();
196196
skipWhitespace(input);
197-
char read = input.read();
197+
int read = input.read();
198198
if (read != ':') {
199199
throw new JsonException(
200-
"Unable to read name. Expected colon separator, but saw '" + read + "'");
200+
"Unable to read name. Expected colon separator, but saw '" + (char) read + "'");
201201
}
202202
return name;
203203
}
@@ -241,13 +241,13 @@ public Number nextNumber() {
241241
case '7':
242242
case '8':
243243
case '9':
244-
builder.append(input.read());
244+
builder.append((char) input.read());
245245
break;
246246
case '.':
247247
case 'e':
248248
case 'E':
249249
mightBeDecimal = true;
250-
builder.append(input.read());
250+
builder.append((char) input.read());
251251
break;
252252
default:
253253
read = false;
@@ -552,11 +552,11 @@ private void expect(JsonType type) {
552552

553553
int toCompareLength = toCompare.length();
554554
for (int i = 0; i < toCompareLength; i++) {
555-
char read = input.read();
555+
int read = input.read();
556556
if (read != toCompare.charAt(i)) {
557557
throw new JsonException(
558558
String.format(
559-
"Unable to read %s. Saw %s at position %d. %s", toCompare, read, i, input));
559+
"Unable to read %s. Saw %s at position %d. %s", toCompare, (char) read, i, input));
560560
}
561561
}
562562

@@ -574,9 +574,8 @@ private String readString() {
574574
input.read(); // Skip leading quote
575575

576576
StringBuilder builder = new StringBuilder();
577-
char c;
578577
while (true) {
579-
c = input.read();
578+
int c = input.read();
580579
switch (c) {
581580
case Input.EOF:
582581
throw new JsonException("Unterminated string: " + builder + ". " + input);
@@ -586,7 +585,13 @@ private String readString() {
586585
readEscape(builder);
587586
break;
588587
default:
589-
builder.append(c);
588+
// RFC 8259 §7: characters U+0000..U+001F MUST be escaped.
589+
if (c < 0x20) {
590+
throw new JsonException(
591+
String.format(
592+
"Illegal unescaped control character U+%04X in string. %s", c, input));
593+
}
594+
builder.append((char) c);
590595
}
591596
}
592597
}
@@ -601,7 +606,7 @@ private String readString() {
601606
*/
602607
// FIXME: This function doesn't appear to support UTF-8 or UTF-32.
603608
private void readEscape(StringBuilder builder) {
604-
char read = input.read();
609+
int read = input.read();
605610

606611
// List from: https://tools.ietf.org/html/rfc7159.html#section-7
607612
switch (read) {
@@ -629,10 +634,10 @@ private void readEscape(StringBuilder builder) {
629634
int result = 0;
630635
int multiplier = 4096; // (16 * 16 * 16) as we start from the thousands and work to units.
631636
for (int i = 0; i < 4; i++) {
632-
char c = input.read();
637+
int c = input.read();
633638
int digit = Character.digit(c, 16);
634639
if (digit == -1) {
635-
throw new JsonException(c + " is not a hexadecimal digit. " + input);
640+
throw new JsonException((char) c + " is not a hexadecimal digit. " + input);
636641
}
637642
result += digit * multiplier;
638643
multiplier /= 16;
@@ -643,11 +648,11 @@ private void readEscape(StringBuilder builder) {
643648
case '/':
644649
case '\\':
645650
case '"':
646-
builder.append(read);
651+
builder.append((char) read);
647652
break;
648653

649654
default:
650-
throw new JsonException("Unexpected escape code: " + read + ". " + input);
655+
throw new JsonException("Unexpected escape code: " + (char) read + ". " + input);
651656
}
652657
}
653658

java/test/org/openqa/selenium/json/JsonInputTest.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,40 @@ void shouldBeAbleToReadNonWellFormedDataLongerThanReadBuffer() {
291291
}
292292
}
293293

294+
@Test
295+
void shouldReadU_FFFF_AsALiteralCharacterAndNotEndOfInput() {
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);
305+
}
306+
307+
try (JsonInput input = newInput("\"\\uFFFF\"")) {
308+
assertThat(input.nextString()).isEqualTo(String.valueOf(nonChar));
309+
}
310+
}
311+
312+
@Test
313+
void shouldRejectUnescapedControlCharactersInStrings() {
314+
// RFC 8259 §7: characters U+0000..U+001F MUST be escaped in JSON strings.
315+
// A literal newline / tab / etc. inside quotes is not valid JSON.
316+
try (JsonInput input = newInput("\"a\nb\"")) {
317+
assertThatExceptionOfType(JsonException.class)
318+
.isThrownBy(input::nextString)
319+
.withMessageStartingWith("Illegal unescaped control character");
320+
}
321+
322+
// Escaped equivalents are still fine.
323+
try (JsonInput input = newInput("\"a\\nb\"")) {
324+
assertThat(input.nextString()).isEqualTo("a\nb");
325+
}
326+
}
327+
294328
@Test
295329
void nullInputsShouldCoerceAsNullValues() throws IOException {
296330
try (InputStream is = new ByteArrayInputStream(new byte[0]);

0 commit comments

Comments
 (0)