GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Auto-port 4.1: Stop DateFormatter trailing token from running past th… · netty/netty@dc68016

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • codec/src
    • main/java/io/netty/handler/codec
      • DateFormatter.java
    • test/java/io/netty/handler/codec
      • DateFormatterTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎codec/src/main/java/io/netty/handler/codec/DateFormatter.java‎

Copy file name to clipboardExpand all lines: codec/src/main/java/io/netty/handler/codec/DateFormatter.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,8 @@ private boolean parse1(CharSequence txt, int start, int end) {
388388
}
389389
}
390390

391-
// terminate trailing token
392-
return tokenStart != -1 && parseToken(txt, tokenStart, txt.length());
391+
// terminate trailing token at end, not txt.length(), so a substring parse doesn't overrun
392+
return tokenStart != -1 && parseToken(txt, tokenStart, end);
393393
}
394394

395395
private boolean normalizeAndValidate() {
Collapse file

‎codec/src/test/java/io/netty/handler/codec/DateFormatterTest.java‎

Copy file name to clipboardExpand all lines: codec/src/test/java/io/netty/handler/codec/DateFormatterTest.java
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ public void testParseWithSingleDigitDay() {
3737
assertEquals(DATE, parseHttpDate("Sun, 6 Nov 1994 08:49:37 GMT"));
3838
}
3939

40+
@Test
41+
public void testParseHttpDateSubstringDoesNotOverrunEnd() {
42+
// Set-Cookie header format with the date anywhere but last (RFC 6265 tokens are unordered).
43+
String dateText = "Sun 08:49:37 06 Nov 1994";
44+
assertEquals(DATE, parseHttpDate(dateText));
45+
assertEquals(DATE, parseHttpDate(dateText + "; Path=/", 0, dateText.length()));
46+
}
47+
4048
@Test
4149
public void testParseWithDoubleDigitDay() {
4250
assertEquals(DATE, parseHttpDate("Sun, 06 Nov 1994 08:49:37 GMT"));

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.