Show pictures in descriptions, or links to them when turned off
[img] in a channel, client or server description is now a picture on both clients, as TeamSpeak shows it; chat keeps it a link. Only web addresses become pictures. While one loads it is TeamSpeak's loading icon; one that cannot be had is its address behind the broken-picture icon. "Show pictures in descriptions" (desktop: Chat settings; Android: Appearance) turns them into links behind a picture icon instead, fetching nothing. A picture that was itself a link keeps that link beside it. Core's PictureDownloads fetches them for both clients: kept on disk for a month after last shown, at most 8 MB, redirects followed across http and https, and on Android plain http asked for over https. The desktop draws them narrowed to the info panel, Android at a pixel to a dp, animated GIFs playing on both; long addresses are shortened to host and file name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ package com.ts3client.text;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
|
||||
/** The block tags TeamSpeak's own client renders in descriptions. */
|
||||
class BBCodeTagsTest {
|
||||
@@ -31,4 +32,36 @@ class BBCodeTagsTest {
|
||||
BBCode.toHtml("[table][tr][th]h[/th][td]d[/td][/tr][/table]"));
|
||||
assertEquals("[td]loose[/td]", BBCode.toHtml("[td]loose[/td]"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void showsPicturesOnlyWhereAsked() {
|
||||
String bb = "[img]https://example.com/a.png[/img]";
|
||||
assertEquals("<img src=\"https://example.com/a.png\">", BBCode.toHtml(bb, true));
|
||||
assertEquals("<a class=\"extlink\" href=\"https://example.com/a.png\">https://example.com/a.png</a>",
|
||||
BBCode.toHtml(bb));
|
||||
}
|
||||
|
||||
@Test
|
||||
void linksPicturesInsideALink() {
|
||||
assertEquals("<a class=\"extlink\" href=\"https://x.org\"><img src=\"http://x.org/b.gif\"></a>",
|
||||
BBCode.toHtml("[url=https://x.org][img]http://x.org/b.gif[/img][/url]", true));
|
||||
}
|
||||
|
||||
@Test
|
||||
void showsNoPictureFromElsewhereThanTheWeb() {
|
||||
assertEquals("[img]file:///etc/passwd[/img]", BBCode.toHtml("[img]file:///etc/passwd[/img]", true));
|
||||
assertFalse(BBCode.toHtml("[img=https://x.org/a.png]", true).contains("<img"), "only [img]…[/img] is a picture");
|
||||
}
|
||||
|
||||
@Test
|
||||
void escapesThePictureAddress() {
|
||||
assertEquals("<img src=\"https://x.org/a.png?a=1&b=2\">", BBCode.toHtml("[img]https://x.org/a.png?a=1&b=2[/img]", true));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shortensLongAddressesToHostAndFile() {
|
||||
assertEquals("https://x.org/a.png", BBCode.shortAddress("https://x.org/a.png"));
|
||||
assertEquals("upload.wikimedia.org/…/250px-Example.png", BBCode.shortAddress(
|
||||
"https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/Example.png/250px-Example.png"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user