diff options
author | David Benson <david@draw.io> | 2022-09-01 22:14:02 +0300 |
---|---|---|
committer | David Benson <david@draw.io> | 2022-09-01 22:14:02 +0300 |
commit | 59887e45b36f06c8dd4919a32bacd994d9f084da (patch) | |
tree | b5e342c0c898e9f8c68ae0512aaaadefb09fd260 /etc | |
parent | 0e6f27fa4a92339867369a33cfcafe521028fda6 (diff) |
20.2.8 releasev20.2.8
Diffstat (limited to 'etc')
-rw-r--r-- | etc/build/Xml2Js.class | bin | 6137 -> 5370 bytes | |||
-rw-r--r-- | etc/build/Xml2Js.java | 93 |
2 files changed, 5 insertions, 88 deletions
diff --git a/etc/build/Xml2Js.class b/etc/build/Xml2Js.class Binary files differindex 35545ad6..05f130f7 100644 --- a/etc/build/Xml2Js.class +++ b/etc/build/Xml2Js.class diff --git a/etc/build/Xml2Js.java b/etc/build/Xml2Js.java index e941a492..f9e884e1 100644 --- a/etc/build/Xml2Js.java +++ b/etc/build/Xml2Js.java @@ -15,6 +15,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; import java.util.zip.Deflater; +import java.util.Base64; public class Xml2Js { @@ -73,12 +74,8 @@ public class Xml2Js */ public static String processFile(File file) throws IOException { - System.out.println("Processing " + file.getCanonicalPath() + "..."); - - Deflater deflater = new Deflater(Deflater.DEFAULT_COMPRESSION, true); - byte[] inBytes = encodeURIComponent( - readInputStream(new FileInputStream(file)), - CHARSET_FOR_URL_ENCODING).getBytes("UTF-8"); + Deflater deflater = new Deflater(Deflater.BEST_COMPRESSION, true); + byte[] inBytes = readInputStream(new FileInputStream(file)).getBytes("UTF-8"); deflater.setInput(inBytes); ByteArrayOutputStream outputStream = new ByteArrayOutputStream( @@ -94,7 +91,7 @@ public class Xml2Js outputStream.close(); - return encodeToString(outputStream.toByteArray(), false); + return Base64.getEncoder().encodeToString(outputStream.toByteArray()); } /** @@ -160,85 +157,6 @@ public class Xml2Js IA['='] = 0; } - // **************************************************************************************** - // * char[] version - // **************************************************************************************** - - /** Encodes a raw byte array into a BASE64 <code>char[]</code> representation i accordance with RFC 2045. - * @param sArr The bytes to convert. If <code>null</code> or length 0 an empty array will be returned. - * @param lineSep Optional "\r\n" after 76 characters, unless end of file.<br> - * No line separator will be in breach of RFC 2045 which specifies max 76 per line but will be a - * little faster. - * @return A BASE64 encoded array. Never <code>null</code>. - */ - public final static char[] encodeToChar(byte[] sArr, boolean lineSep) - { - // Check special case - int sLen = sArr != null ? sArr.length : 0; - if (sLen == 0) - return new char[0]; - - int eLen = (sLen / 3) * 3; // Length of even 24-bits. - int cCnt = ((sLen - 1) / 3 + 1) << 2; // Returned character count - int dLen = cCnt + (lineSep ? (cCnt - 1) / 76 << 1 : 0); // Length of returned array - char[] dArr = new char[dLen]; - - // Encode even 24-bits - for (int s = 0, d = 0, cc = 0; s < eLen;) - { - // Copy next three bytes into lower 24 bits of int, paying attension to sign. - int i = (sArr[s++] & 0xff) << 16 | (sArr[s++] & 0xff) << 8 - | (sArr[s++] & 0xff); - - // Encode the int into four chars - dArr[d++] = CA[(i >>> 18) & 0x3f]; - dArr[d++] = CA[(i >>> 12) & 0x3f]; - dArr[d++] = CA[(i >>> 6) & 0x3f]; - dArr[d++] = CA[i & 0x3f]; - - // Add optional line separator - if (lineSep && ++cc == 19 && d < dLen - 2) - { - dArr[d++] = '\r'; - dArr[d++] = '\n'; - cc = 0; - } - } - - // Pad and encode last bits if source isn't even 24 bits. - int left = sLen - eLen; // 0 - 2. - if (left > 0) - { - // Prepare the int - int i = ((sArr[eLen] & 0xff) << 10) - | (left == 2 ? ((sArr[sLen - 1] & 0xff) << 2) : 0); - - // Set last four chars - dArr[dLen - 4] = CA[i >> 12]; - dArr[dLen - 3] = CA[(i >>> 6) & 0x3f]; - dArr[dLen - 2] = left == 2 ? CA[i & 0x3f] : '='; - dArr[dLen - 1] = '='; - } - return dArr; - } - - // **************************************************************************************** - // * String version - // **************************************************************************************** - - /** Encodes a raw byte array into a BASE64 <code>String</code> representation i accordance with RFC 2045. - * @param sArr The bytes to convert. If <code>null</code> or length 0 an empty array will be returned. - * @param lineSep Optional "\r\n" after 76 characters, unless end of file.<br> - * No line separator will be in breach of RFC 2045 which specifies max 76 per line but will be a - * little faster. - * @return A BASE64 encoded array. Never <code>null</code>. - */ - public final static String encodeToString(byte[] sArr, boolean lineSep) - { - // Reuse char[] since we can't create a String incrementally anyway and StringBuffer/Builder would be slower. - return new String(encodeToChar(sArr, lineSep)); - } - /** * Main */ @@ -275,10 +193,9 @@ public class Xml2Js result.append(" var t = f[filename.substring(STENCIL_PATH.length + 1)];\n"); result.append(" var s = null;\n"); result.append(" if (t != null) {\n"); - result.append(" t = pako.inflateRaw(Uint8Array.from(atob(t), function (c) {\n"); + result.append(" s = pako.inflateRaw(Uint8Array.from(atob(t), function (c) {\n"); result.append(" return c.charCodeAt(0);\n"); result.append(" }), {to: 'string'});\n"); - result.append(" s = decodeURIComponent(t);\n"); result.append(" }\n"); result.append(" if (fn != null && s != null) {\n"); result.append( |