Skip to content

Commit

Permalink
Fix TCVN-3, add charsets to about page
Browse files Browse the repository at this point in the history
Closes #1290
Closes #281
  • Loading branch information
tresf committed Sep 4, 2024
1 parent cbece76 commit 7330141
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
27 changes: 27 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,33 @@
</fileset>
</delete>

<!-- Merge META-INF/services from TCVN-3, icu4j-charset-slim -->
<!-- find the icu4j-charset-slim jar -->
<path id="icu4j-slim.found">
<first>
<fileset dir="lib/charsets/">
<include name="icu4j-charset-*.jar"/>
</fileset>
</first>
</path>
<pathconvert property="icu4j-slim.path" refid="icu4j-slim.found"/>

<!-- find the TCVN-3 jar -->
<path id="tcvn-3.found">
<first>
<fileset dir="lib/charsets/">
<include name="TCVN-3*.jar"/>
</fileset>
</first>
</path>
<pathconvert property="tcvn-3.path" refid="tcvn-3.found"/>

<!-- merge service entries for CharsetProvider -->
<concat destfile="${out.dir}/libs-temp/META-INF/services/java.nio.charset.spi.CharsetProvider" fixlastline="true">
<zipentry zipfile="${icu4j-slim.path}" name="META-INF/services/java.nio.charset.spi.CharsetProvider"/>
<zipentry zipfile="${tcvn-3.path}" name="META-INF/services/java.nio.charset.spi.CharsetProvider"/>
</concat>

<!-- Merge META-INF/services from PDFBOX, jpeg2000 and TwelveMonkeys -->
<!-- find the TwelveMonkeys jar -->
<path id="imageio-jpeg.found">
Expand Down
15 changes: 15 additions & 0 deletions src/qz/common/AboutInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.InputStreamReader;
import java.lang.management.ManagementFactory;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.GeneralSecurityException;
import java.security.cert.CertificateEncodingException;
Expand All @@ -46,6 +47,7 @@ public static JSONObject gatherAbout(String domain, CertificateManager certifica
about.put("environment", environment());
about.put("ssl", ssl(certificateManager));
about.put("libraries", libraries());
about.put("charsets", charsets());
}
catch(JSONException | GeneralSecurityException e) {
log.error("Failed to write JSON data", e);
Expand Down Expand Up @@ -153,6 +155,19 @@ private static JSONObject libraries() throws JSONException {
return libraries;
}

private static JSONObject charsets() throws JSONException {
JSONObject charsets = new JSONObject();

SortedMap<String,Charset> avail = Charset.availableCharsets();
ArrayList<String> names = new ArrayList<>();
for(Map.Entry<String,Charset> entry : avail.entrySet()) {
names.add(entry.getValue().name());
}

charsets.put("charsets", Arrays.toString(names.toArray()));
return charsets;
}

public static String getPreferredHostname() {
return preferredHostname;
}
Expand Down

0 comments on commit 7330141

Please sign in to comment.