Skip to content

Commit

Permalink
Validate string length
Browse files Browse the repository at this point in the history
Fixes #1172
  • Loading branch information
jhy committed May 12, 2019
1 parent 315655c commit 7de614f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ jsoup changelog
* Bugfix: Element.shallowClone() was not making a clone of its attributes.
<https://github.com/jhy/jsoup/issues/1201>

* Bugfix: fixed an ArrayIndexOutOfBoundsException in HttpConnection.looksLikeUtf8 when testing small strings in
specific ranges.
<https://github.com/jhy/jsoup/issues/1172>

* Updated jetty-server (which is used for integration tests) to latest 9.2 series (9.2.28).

*** Release 1.11.3 [2018-Apr-15]
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/jsoup/helper/HttpConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,9 @@ private static boolean looksLikeUtf8(byte[] input) {
return false;
}

if (end >= input.length)
return false;

while (i < end) {
i++;
o = input[i];
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/org/jsoup/helper/HttpConnectionTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jsoup.helper;

import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.MultiLocaleRule;
import org.jsoup.MultiLocaleRule.MultiLocaleTest;
import org.jsoup.integration.ParseTest;
Expand Down Expand Up @@ -249,4 +250,9 @@ public class HttpConnectionTest {
}
assertTrue(threw);
}

@Test public void handlesHeaderEncodingOnRequest() {
Connection.Request req = new HttpConnection.Request();
req.addHeader("xxx", "é");
}
}

0 comments on commit 7de614f

Please sign in to comment.