Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Unexpected exception when parsing URL with specific percent encoding #14

@jmichalica

Description

@jmichalica

Hi, when parsing specific URL via com.anthonynsimon.url.URL.parse(String), a StringIndexOutOfBoundsException is thrown.

The input URL: http://a-create-labo.biz/photo/2011/02/18/abs%e6%a8%b9%e8%84%82%e8%a3%bd%e3%25

The stack trace:

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
	at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55)
	at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52)
	at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213)
	at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210)
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98)
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
	at java.base/java.lang.String.checkIndex(String.java:4832)
	at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:46)
	at java.base/java.lang.String.charAt(String.java:1555)
	at com.anthonynsimon.url.PercentEncoder.decode(PercentEncoder.java:176)
	at com.anthonynsimon.url.DefaultURLParser.parse(DefaultURLParser.java:82)
	at com.anthonynsimon.url.URL.parse(URL.java:107)

The encoded part seems to represent a malformed multibyte unicode character sequence (as seen from decoded value: http://a-create-labo.biz/photo/2011/02/18/abs樹脂製�%).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions