Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-15077

Clickable links in Chat are broken for many valid URL formats

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Resolution: Fixed
    • Minecraft 1.5.1, Minecraft 1.6.1, Minecraft 1.6.2
    • Minecraft 1.10.2
    • None
    • Community Consensus

    Description

      The regex used in ChatClickData doesn't match on valid URLs which use an IP4 address, port, hash (#), or have comma in the query string. This makes a large variety of valid URLs "un-clickable" in the Chat GUI.

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

      As a fix, the proposed regex will accept either TLD or IP4, optionally allows port, and accepts a hash or commas in the query string:

      ChatClickData
      Pattern pattern = Pattern.compile("^(https?:\\/\\/)?"+ // protocol
            "((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|"+ // domain name
            "((\\d{1,3}\\.){3}\\d{1,3}))"+ // OR ip (v4) address
            "(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*"+ // port and path
            "(\\?[;&a-z\\d%_.~+=-]*)?"+ // query string
            "(\\#[-a-z\\d_]*)?$"); // hash

      Here's a JSFiddle showing the current and proposed regexes in action:

      http://jsfiddle.net/mwoodman/UycV9/

      Note that the current regex is failing to match on more than half of the URLs tested (2766 out of 4704). The proposed regex passes all of the URLs tested.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mwoodman Mark Woodman
              Votes:
              5 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                CHK: