[MC-291] Screenshots are treated as links in the console. Created: 25/Oct/12  Updated: 21/Aug/14  Resolved: 18/Sep/13

Status: Resolved
Project: Minecraft: Java Edition
Component/s: None
Affects Version/s: Minecraft 1.4.1, Minecraft 1.4.2, Minecraft 1.4.3, Minecraft 1.4.4, Minecraft 1.4.5, Snapshot 12w50b, Snapshot 13w03a, Minecraft 1.5, Snapshot 13w11a, Minecraft 1.5.1, Snapshot 13w16a, Minecraft 1.5.2, Snapshot 13w19a, Snapshot 13w21a, Minecraft 1.6.1, Minecraft 1.6.2
Fix Version/s: Minecraft 13w37a

Type: Bug
Reporter: 5ives Assignee: Unassigned
Resolution: Invalid Votes: 7
Labels: None
Environment:

Windows 7 64bit, Java 7 (1.7.0_09)


Issue Links:
Duplicate
is duplicated by MC-10855 screenshots & sleeping Resolved
is duplicated by MC-26456 Cant sleep and having multiple sleepi... Resolved
CHK:
Confirmation Status: Confirmed

 Description   

When saving a screenshot then clicking on it in the console, Minecraft treats it as a link to a website and opens for e.g. literally '2012-12-25_00.00.00.png' in your default web browser.

What I excepted:
When clicking on the screenshot it should either open in your default image viewer with the path or in your default browser with the path and the 'file:///' prefix.
What happened:
Your default browser opens with the file name of the screenshot as the URL.

To reproduce:
1. Pres F2 to take a screenshot.
2. Press 't' to open the console.
3. Click on the name of the screenshot. E.g "Saved screenshot as 2012-12-25_00.00.00.png"
4. '2012-12-25_00.00.00.png' opens as a URL in your default browser.



 Comments   
Comment by Player_Char [ 18/Sep/13 ]

Fixed for 13w37a. Now it is a link to your screenshot instead an internet link.

Comment by [Mod] Ezekiel (ezfe) [ 11/Jul/13 ]

Confirmed for 1.6.2

Comment by Anon Ymus [ 22/Mar/13 ]

Confirmed.

Comment by Daniel "Glampkoo" [ 12/Mar/13 ]

Confirmed for 1.5pre

Comment by Markku [ 03/Mar/13 ]

Affects 13w09c.

Comment by Markku [ 03/Mar/13 ]

The bug here is that it thinks those are host names. The format is valid for one, but... perhaps it should exclude '.png' just to evade this issue.

Then again, might as well detect those and convert them into file links. Bug fix and a decent feature in one change. Like this...

Fix

ChatClickData
    // ADDED:
    public static final Pattern PATTERN_SCREENSHOT = Pattern.compile("^\\d{4}-\\d{2}-\\d{2}_\\d{2}\\.\\d{2}\\.\\d{2}\\.png$");

    ...

    public URI getURI() {
        String var1 = this.getClickedUrl();

        if (var1 == null)
            return null;

        // ADDED:
        Matcher screenshotMatcher = PATTERN_SCREENSHOT.matcher(var1);
        if (screenshotMatcher.matches()) {
            String match = screenshotMatcher.group(0);
            File mcDir = Minecraft.getMinecraftDir();
            try {
                mcDir = mcDir.getCanonicalFile();
            } catch (IOException e) {
                Logger.getLogger("Minecraft").log(Level.SEVERE, "Spooky Minecraft home directory?", e);
                return null;
            }
            File ssDir = new File(mcDir, "screenshots");
            File ssFile = new File(ssDir, match);
            return ssFile.toURI();
        }

        // OLD STUFF CONTINUES...
        Matcher var2 = pattern.matcher(var1);
        ...

Tested on 1.4.7. On my Windows 7, it opened the screenshot using IrfanView (my default viewer application), so couldn't have worked better. Note, the canonical-part is good to be; it removes possibly lingering \.\ stuff in the end etc., which if left there will cause trouble.

Edit:
Clicking on screenshot when the confirmation dialog is enabled makes it a bit misleading, as the confirmation talks about websites. Own screenshots should be safe to click on at any time, so it is better to just skip the confirmation if the match is detected as a screenshot. This can be semi-exploited by someone else chatting a screenshot file name, which may or may not exist on the player's own computer, and the player clicking on that filename. But that would not cause a security vulnerability, merely a minor nuisance.

ChatClickData
    // ADDED METHOD
    public boolean isScreenshot() {
        String var1 = this.getClickedUrl();
        if (var1 == null)
            return false;
        Matcher screenshotMatcher = PATTERN_SCREENSHOT.matcher(var1);
        return screenshotMatcher.matches();
    }
GuiChat.mouseClicked()
            if (var5 != null) {
                // ADDED THAT !isScreenshot() CHECK
                if (!var4.isScreenshot() && this.mc.gameSettings.chatLinksPrompt) {
                    this.clickedURI = var5;
                    this.mc.displayGuiScreen(new GuiConfirmOpenLink(this, var4.getClickedUrl(), 0));
                } ...
Comment by Gravity [ 25/Oct/12 ]

The reason behind this is that URLs are relatively hard to accurately find in text. Minecraft, therefor, marks a lot more things as URLs than it actually should, which is better than the alternative which is sometimes not marking a URL at all, and possibly making someone frustrated.

With that said, it may be possible to tag these as non-urls or maybe link them to a place on your hard drive instead of the net, because Minecraft generates these itself. I'm not going to mark this as confirmed, though, because it's not really a bug.

Comment by Charles-William Crete [ 25/Oct/12 ]

This is normal. The picture path is linked up to the screenshot 000-00-00_00.00.00.png. Every file on your hard drive has a local URL. Not really a bug but could be improved.

Generated at Sun Jan 12 11:50:32 UTC 2025 using Jira 9.12.2#9120002-sha1:301bf498dd45d800842af0b84230f1bb58606c13.