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.
Linked issues
is duplicated by 2
Comments 8
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.
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));
} ...
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.