Skip to content

Commit

Permalink
Make XHTML example more null-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Oct 18, 2024
1 parent b6c2c59 commit 9f5a4d9
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

import org.apache.commons.cli.help.FilterHelpAppendable;
import org.apache.commons.cli.help.TableDefinition;
Expand Down Expand Up @@ -46,7 +47,7 @@ public void appendHeader(final int level, final CharSequence text) throws IOExce
if (level < 1) {
throw new IllegalArgumentException("level must be at least 1");
}
appendFormat("<h%s>%s</h%1$s>%n", level, StringEscapeUtils.escapeHtml4(text.toString()));
appendFormat("<h%s>%s</h%1$s>%n", level, StringEscapeUtils.escapeHtml4(Objects.toString(text)));
}
}

Expand All @@ -62,7 +63,7 @@ public void appendList(final boolean ordered, final Collection<CharSequence> lis
@Override
public void appendParagraph(final CharSequence paragraph) throws IOException {
if (StringUtils.isNotEmpty(paragraph)) {
appendFormat("<p>%s</p>%n", StringEscapeUtils.escapeHtml4(paragraph.toString()));
appendFormat("<p>%s</p>%n", StringEscapeUtils.escapeHtml4(Objects.toString(paragraph)));
}
}

Expand Down Expand Up @@ -93,6 +94,6 @@ public void appendTable(final TableDefinition table) throws IOException {

@Override
public void appendTitle(final CharSequence title) throws IOException {
appendFormat("<span class='commons_cli_title'>%s</span>%n", StringEscapeUtils.escapeHtml4(title.toString()));
appendFormat("<span class='commons_cli_title'>%s</span>%n", StringEscapeUtils.escapeHtml4(Objects.toString(title)));
}
}

0 comments on commit 9f5a4d9

Please sign in to comment.