mojira.dev
MC-8437

URL parser does not detect 4 letter TLDs

The URL parsing in chat dislikes Top Level Domains with more than 3 characters (eg a .com works fine, but a .info does not), and does not permit clicking on the link in game to take the user to a web address.

The problem is easily reproduced, after trying the domains in the chat box:

jameo.com and other variations (eg prepending http://) functions correctly.

jameo.info and other variations do not.

Linked issues

Comments 4

Bug confirmed, found and busted. Erm, fixed.

Bug

"ChatClickData"

public static final Pattern pattern = Pattern.compile("^(?:(https?)://)?([-\\w_\\.]{2,}\\.[a-z]{2,3})(/\\S*)?$");

Fix

"ChatClickData"

public static final Pattern pattern = Pattern.compile("^(?:(https?)://)?([-\\w_\\.]{2,}\\.[a-z]{2,4})(/\\S*)?$");

Fix tested on 1.4.7

(Edit: minor technical detail: It does allow clicking the text in any case, it just won't recognize it as an URL without that small change, and thus will not react any further.)

http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains
Not every TLD will catched by this RegEx. You should avoid "TLD can be only 2-4 characters long" type of thinking.

Jake Fisher

Nathan Adams

Confirmed

chat

Minecraft 1.4.7, Snapshot 13w04a

Snapshot 13w05a

Retrieved