Quoted-printable encode HTML messages on the WebCit Server side.
[citadel.git] / webcit-ng / static / js / util.js
index 725fc4944f6088a5fa715309a9e50a94c2196450..1f3ae65f8806b961333089a0e8a6566dbd656f55 100644 (file)
@@ -4,36 +4,37 @@
 // disclosure are subject to the GNU General Public License v3.
 
 
-// Function to encode data in quoted-printable format
-// Written by Theriault and Brett Zamir [https://locutus.io/php/quoted_printable_encode/]
-function quoted_printable_encode(str) {
-       const hexChars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']
-       const RFC2045Encode1IN = / \r\n|\r\n|[^!-<>-~ ]/gm
-       const RFC2045Encode1OUT = function (sMatch) {
-               // Encode space before CRLF sequence to prevent spaces from being stripped
-               // Keep hard line breaks intact; CRLF sequences
-               if (sMatch.length > 1) {
-                       return sMatch.replace(' ', '=20');
-               }
-               // Encode matching character
-               const chr = sMatch.charCodeAt(0);
-               return '=' + hexChars[((chr >>> 4) & 15)] + hexChars[(chr & 15)];
-       }
-       // Split lines to 75 characters; the reason it's 75 and not 76 is because softline breaks are
-       // preceeded by an equal sign; which would be the 76th character. However, if the last line/string
-       // was exactly 76 characters, then a softline would not be needed. PHP currently softbreaks
-       // anyway; so this function replicates PHP.
-       const RFC2045Encode2IN = /.{1,72}(?!\r\n)[^=]{0,3}/g
-       const RFC2045Encode2OUT = function (sMatch) {
-               if (sMatch.substr(sMatch.length - 2) === '\r\n') {
-                       return sMatch;
-               }
-               return sMatch + '=\r\n';
-       }
-       str = str.replace(RFC2045Encode1IN, RFC2045Encode1OUT).replace(RFC2045Encode2IN, RFC2045Encode2OUT);
-       // Strip last softline break
-       return str.substr(0, str.length - 3)
-}
+//     // (We don't need this anymore because we encode on the server side)
+//     // Function to encode data in quoted-printable format
+//     // Written by Theriault and Brett Zamir [https://locutus.io/php/quoted_printable_encode/]
+//     function quoted_printable_encode(str) {
+//             const hexChars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']
+//             const RFC2045Encode1IN = / \r\n|\r\n|[^!-<>-~ ]/gm
+//             const RFC2045Encode1OUT = function (sMatch) {
+//                     // Encode space before CRLF sequence to prevent spaces from being stripped
+//                     // Keep hard line breaks intact; CRLF sequences
+//                     if (sMatch.length > 1) {
+//                             return sMatch.replace(' ', '=20');
+//                     }
+//                     // Encode matching character
+//                     const chr = sMatch.charCodeAt(0);
+//                     return '=' + hexChars[((chr >>> 4) & 15)] + hexChars[(chr & 15)];
+//             }
+//             // Split lines to 75 characters; the reason it's 75 and not 76 is because softline breaks are
+//             // preceeded by an equal sign; which would be the 76th character. However, if the last line/string
+//             // was exactly 76 characters, then a softline would not be needed. PHP currently softbreaks
+//             // anyway; so this function replicates PHP.
+//             const RFC2045Encode2IN = /.{1,72}(?!\r\n)[^=]{0,3}/g
+//             const RFC2045Encode2OUT = function (sMatch) {
+//                     if (sMatch.substr(sMatch.length - 2) === '\r\n') {
+//                             return sMatch;
+//                     }
+//                     return sMatch + '=\r\n';
+//             }
+//             str = str.replace(RFC2045Encode1IN, RFC2045Encode1OUT).replace(RFC2045Encode2IN, RFC2045Encode2OUT);
+//             // Strip last softline break
+//             return str.substr(0, str.length - 3)
+//     }
 
 
 // generate a random string -- mainly used for generating one-time-use div names