Skip to content

Commit dca61c5

Browse files
Merge pull request #53 from UmamiAppearance/uuencode_original_fixes
Uuencode original fixes
2 parents a206d34 + 44e0e0d commit dca61c5

File tree

13 files changed

+91
-38
lines changed

13 files changed

+91
-38
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ The **Ex** in the name stands for **Ex**ponent (of n) or - as read out loud - fo
288288
<li>base64</li>
289289
<li>base64_urlsafe</li>
290290
<li>uuencode</li>
291+
<li>uuencode_original</li>
291292
<li>xxencode</li>
292293
<li>base85_adobe</li>
293294
<li>base85_ascii</li>

cjs/base-ex.cjs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,13 +2055,14 @@ class Base64 extends BaseTemplate {
20552055
* BaseEx UUencode Converter.
20562056
* ------------------------
20572057
*
2058-
* This is a base64 converter. Various input can be
2059-
* converted to a base64 string or a base64 string
2058+
* This is a UUencoder/UUdecoder. Various input can be
2059+
* converted to a UUencoded string or a UUencoded string
20602060
* can be decoded into various formats.
20612061
*
20622062
* Available charsets are:
20632063
* - default
2064-
* - urlsafe
2064+
* - original
2065+
* - xx
20652066
*/
20662067
class UUencode extends BaseTemplate {
20672068

@@ -2170,7 +2171,7 @@ class UUencode extends BaseTemplate {
21702171
const format = ({ input, settings }) => {
21712172

21722173
const charset = this.charsets[settings.version];
2173-
const lines = input.trim().split("\n");
2174+
const lines = input.trim().split(/\r?\n/);
21742175
const inArray = [];
21752176

21762177
if ((/^begin/i).test(lines.at(0))) {
@@ -2187,10 +2188,17 @@ class UUencode extends BaseTemplate {
21872188

21882189
inArray.push(...lArray);
21892190

2190-
if (byteCount !== 45) {
2191+
if (byteCount !== 45) {
21912192
padChars = this.converter.padChars(lArray.length) - byteCount;
21922193
break;
21932194
}
2195+
2196+
// fix probably missing spaces for original charset
2197+
else if (lArray.length !== 60 && settings.version === "original") {
2198+
while (inArray.length % 60) {
2199+
inArray.push(" ");
2200+
}
2201+
}
21942202
}
21952203

21962204
return inArray.join("");
@@ -3896,6 +3904,7 @@ class BaseEx {
38963904
this.base64 = new Base64("default", outputType);
38973905
this.base64_urlsafe = new Base64("urlsafe", outputType);
38983906
this.uuencode = new UUencode("default", outputType);
3907+
this.uuencode_original = new UUencode("original", outputType);
38993908
this.xxencode = new UUencode("xx", outputType);
39003909
this.base85_adobe = new Base85("adobe", outputType);
39013910
this.base85_ascii = new Base85("ascii85", outputType);

cjs/base-ex.cjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/base-ex.esm.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,13 +2053,14 @@ class Base64 extends BaseTemplate {
20532053
* BaseEx UUencode Converter.
20542054
* ------------------------
20552055
*
2056-
* This is a base64 converter. Various input can be
2057-
* converted to a base64 string or a base64 string
2056+
* This is a UUencoder/UUdecoder. Various input can be
2057+
* converted to a UUencoded string or a UUencoded string
20582058
* can be decoded into various formats.
20592059
*
20602060
* Available charsets are:
20612061
* - default
2062-
* - urlsafe
2062+
* - original
2063+
* - xx
20632064
*/
20642065
class UUencode extends BaseTemplate {
20652066

@@ -2168,7 +2169,7 @@ class UUencode extends BaseTemplate {
21682169
const format = ({ input, settings }) => {
21692170

21702171
const charset = this.charsets[settings.version];
2171-
const lines = input.trim().split("\n");
2172+
const lines = input.trim().split(/\r?\n/);
21722173
const inArray = [];
21732174

21742175
if ((/^begin/i).test(lines.at(0))) {
@@ -2185,10 +2186,17 @@ class UUencode extends BaseTemplate {
21852186

21862187
inArray.push(...lArray);
21872188

2188-
if (byteCount !== 45) {
2189+
if (byteCount !== 45) {
21892190
padChars = this.converter.padChars(lArray.length) - byteCount;
21902191
break;
21912192
}
2193+
2194+
// fix probably missing spaces for original charset
2195+
else if (lArray.length !== 60 && settings.version === "original") {
2196+
while (inArray.length % 60) {
2197+
inArray.push(" ");
2198+
}
2199+
}
21922200
}
21932201

21942202
return inArray.join("");
@@ -3894,6 +3902,7 @@ class BaseEx {
38943902
this.base64 = new Base64("default", outputType);
38953903
this.base64_urlsafe = new Base64("urlsafe", outputType);
38963904
this.uuencode = new UUencode("default", outputType);
3905+
this.uuencode_original = new UUencode("original", outputType);
38973906
this.xxencode = new UUencode("xx", outputType);
38983907
this.base85_adobe = new Base85("adobe", outputType);
38993908
this.base85_ascii = new Base85("ascii85", outputType);

dist/base-ex.esm.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/base-ex.iife.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2056,13 +2056,14 @@ var BaseEx = (function (exports) {
20562056
* BaseEx UUencode Converter.
20572057
* ------------------------
20582058
*
2059-
* This is a base64 converter. Various input can be
2060-
* converted to a base64 string or a base64 string
2059+
* This is a UUencoder/UUdecoder. Various input can be
2060+
* converted to a UUencoded string or a UUencoded string
20612061
* can be decoded into various formats.
20622062
*
20632063
* Available charsets are:
20642064
* - default
2065-
* - urlsafe
2065+
* - original
2066+
* - xx
20662067
*/
20672068
class UUencode extends BaseTemplate {
20682069

@@ -2171,7 +2172,7 @@ var BaseEx = (function (exports) {
21712172
const format = ({ input, settings }) => {
21722173

21732174
const charset = this.charsets[settings.version];
2174-
const lines = input.trim().split("\n");
2175+
const lines = input.trim().split(/\r?\n/);
21752176
const inArray = [];
21762177

21772178
if ((/^begin/i).test(lines.at(0))) {
@@ -2188,10 +2189,17 @@ var BaseEx = (function (exports) {
21882189

21892190
inArray.push(...lArray);
21902191

2191-
if (byteCount !== 45) {
2192+
if (byteCount !== 45) {
21922193
padChars = this.converter.padChars(lArray.length) - byteCount;
21932194
break;
21942195
}
2196+
2197+
// fix probably missing spaces for original charset
2198+
else if (lArray.length !== 60 && settings.version === "original") {
2199+
while (inArray.length % 60) {
2200+
inArray.push(" ");
2201+
}
2202+
}
21952203
}
21962204

21972205
return inArray.join("");
@@ -3897,6 +3905,7 @@ var BaseEx = (function (exports) {
38973905
this.base64 = new Base64("default", outputType);
38983906
this.base64_urlsafe = new Base64("urlsafe", outputType);
38993907
this.uuencode = new UUencode("default", outputType);
3908+
this.uuencode_original = new UUencode("original", outputType);
39003909
this.xxencode = new UUencode("xx", outputType);
39013910
this.base85_adobe = new Base85("adobe", outputType);
39023911
this.base85_ascii = new Base85("ascii85", outputType);

dist/base-ex.iife.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/converters/UUencode/uuencode.esm.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,13 +1461,14 @@ class BaseTemplate {
14611461
* BaseEx UUencode Converter.
14621462
* ------------------------
14631463
*
1464-
* This is a base64 converter. Various input can be
1465-
* converted to a base64 string or a base64 string
1464+
* This is a UUencoder/UUdecoder. Various input can be
1465+
* converted to a UUencoded string or a UUencoded string
14661466
* can be decoded into various formats.
14671467
*
14681468
* Available charsets are:
14691469
* - default
1470-
* - urlsafe
1470+
* - original
1471+
* - xx
14711472
*/
14721473
class UUencode extends BaseTemplate {
14731474

@@ -1576,7 +1577,7 @@ class UUencode extends BaseTemplate {
15761577
const format = ({ input, settings }) => {
15771578

15781579
const charset = this.charsets[settings.version];
1579-
const lines = input.trim().split("\n");
1580+
const lines = input.trim().split(/\r?\n/);
15801581
const inArray = [];
15811582

15821583
if ((/^begin/i).test(lines.at(0))) {
@@ -1593,10 +1594,17 @@ class UUencode extends BaseTemplate {
15931594

15941595
inArray.push(...lArray);
15951596

1596-
if (byteCount !== 45) {
1597+
if (byteCount !== 45) {
15971598
padChars = this.converter.padChars(lArray.length) - byteCount;
15981599
break;
15991600
}
1601+
1602+
// fix probably missing spaces for original charset
1603+
else if (lArray.length !== 60 && settings.version === "original") {
1604+
while (inArray.length % 60) {
1605+
inArray.push(" ");
1606+
}
1607+
}
16001608
}
16011609

16021610
return inArray.join("");

dist/converters/UUencode/uuencode.esm.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/converters/UUencode/uuencode.iife.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,13 +1464,14 @@ var UUencode = (function () {
14641464
* BaseEx UUencode Converter.
14651465
* ------------------------
14661466
*
1467-
* This is a base64 converter. Various input can be
1468-
* converted to a base64 string or a base64 string
1467+
* This is a UUencoder/UUdecoder. Various input can be
1468+
* converted to a UUencoded string or a UUencoded string
14691469
* can be decoded into various formats.
14701470
*
14711471
* Available charsets are:
14721472
* - default
1473-
* - urlsafe
1473+
* - original
1474+
* - xx
14741475
*/
14751476
class UUencode extends BaseTemplate {
14761477

@@ -1579,7 +1580,7 @@ var UUencode = (function () {
15791580
const format = ({ input, settings }) => {
15801581

15811582
const charset = this.charsets[settings.version];
1582-
const lines = input.trim().split("\n");
1583+
const lines = input.trim().split(/\r?\n/);
15831584
const inArray = [];
15841585

15851586
if ((/^begin/i).test(lines.at(0))) {
@@ -1596,10 +1597,17 @@ var UUencode = (function () {
15961597

15971598
inArray.push(...lArray);
15981599

1599-
if (byteCount !== 45) {
1600+
if (byteCount !== 45) {
16001601
padChars = this.converter.padChars(lArray.length) - byteCount;
16011602
break;
16021603
}
1604+
1605+
// fix probably missing spaces for original charset
1606+
else if (lArray.length !== 60 && settings.version === "original") {
1607+
while (inArray.length % 60) {
1608+
inArray.push(" ");
1609+
}
1610+
}
16031611
}
16041612

16051613
return inArray.join("");

dist/converters/UUencode/uuencode.iife.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/base-ex.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class BaseEx {
6161
this.base64 = new Base64("default", outputType);
6262
this.base64_urlsafe = new Base64("urlsafe", outputType);
6363
this.uuencode = new UUencode("default", outputType);
64+
this.uuencode_original = new UUencode("original", outputType);
6465
this.xxencode = new UUencode("xx", outputType);
6566
this.base85_adobe = new Base85("adobe", outputType);
6667
this.base85_ascii = new Base85("ascii85", outputType);

0 commit comments

Comments
 (0)