Skip to content

Commit

Permalink
Use PlantUML %version() function in footer which also works with Plan…
Browse files Browse the repository at this point in the history
…tUML server.

Signed-off-by: Sjoerd Talsma <sjoerdtalsma@users.noreply.github.com>
  • Loading branch information
sjoerdtalsma committed Dec 30, 2022
1 parent 64ea72f commit 805c0a1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@

import java.io.IOException;
import java.io.OutputStream;
import java.util.regex.Pattern;

public interface PlantumlGenerator {
Pattern HTTP_URLS = Pattern.compile("^https?://");
import static nl.talsmasoftware.umldoclet.uml.plantuml.RemotePlantumlGenerator.HTTP_URLS;

public interface PlantumlGenerator {
static PlantumlGenerator getPlantumlGenerator(Configuration configuration) {
return configuration.plantumlServerUrl()
.filter(url -> HTTP_URLS.matcher(url).find())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@
import java.io.OutputStream;
import java.net.URL;
import java.util.Objects;
import java.util.regex.Pattern;

import static java.util.Objects.requireNonNull;

@SuppressFBWarnings(value = "URLCONNECTION_SSRF_FD", justification = "We only allow http(s) urls.")
public class RemotePlantumlGenerator implements PlantumlGenerator {
public static final Pattern HTTP_URLS = Pattern.compile("^https?://");

private static final String DEFAULT_PLANTUML_BASE_URL = "https://www.plantuml.com/plantuml/";
private static final Transcoder TRANSCODER =
TranscoderImpl.utf8(new AsciiEncoder(), new ArobaseStringCompressor(), new CompressionZlib());
Expand All @@ -41,6 +44,9 @@ public class RemotePlantumlGenerator implements PlantumlGenerator {

public RemotePlantumlGenerator(final String baseUrl) {
String url = Objects.toString(baseUrl, DEFAULT_PLANTUML_BASE_URL);
if (!HTTP_URLS.matcher(url).find()) {
throw new IllegalArgumentException("Unsupported PlantUML server base url: [" + url + "].");
}
if (!url.endsWith("/")) url += "/";
this.baseUrl = url;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ doclet.version=${project.version}

# Messages
doclet.copyright=UML Doclet (C) Copyright Talsma ICT, version: {0}.
doclet.uml.footer=UMLDoclet {0}, PlantUML {1}
plantuml.copyright=This software uses PlantUML (C) Copyright Arnaud Roques, version: {0}.
doclet.uml.footer=UMLDoclet {0}, PlantUML %version()
plantuml.copyright=This software uses PlantUML (C) Copyright Arnaud Roques.
debug.configured.image.formats=Configured image formats to generate: {0}.
debug.skipping.file=Skipping {0}...
debug.replacing.by=Replacing {0} by {1}.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
doclet.copyright=UML Doclet (C) Copyright Talsma ICT, versie: {0}.
plantuml.copyright=Deze software gebruikt PlantUML (C) Copyright Arnaud Roques, versie: {0}.
plantuml.copyright=Deze software gebruikt PlantUML (C) Copyright Arnaud Roques.

debug.configured.image.formats=Afbeeldingsformaten geconfigureerd: {0}.
debug.skipping.file=Overslaan {0}...
Expand Down

0 comments on commit 805c0a1

Please sign in to comment.