Skip to content

Commit a1ce4bd

Browse files
committed
FIX: better handling missing padding of the DEBASE (64) input
Now it is handled only when the input is as URL safe variant. Relates to: metaeducation/rebol-issues#2318 Possible test: ``` binary? try [debase { 4BzEEOtIpmVdVEZNCqS7baC4crd0pqnRH_5IB3jw3bcxGn6QLvnEtfdUdi YrqBdss1l58BQ3KhooKeQTa9AB0Hw_Py5PJdTJNPY8cQn7ouZ2KKDcmnPG BY5t7yLc1QlQ5xHdwW1VhvKn-nXqhJTBgIPgtldC-KDV5z-y2XDwGUc }] ;== should be TRUE ```
1 parent b54e1b8 commit a1ce4bd

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/core/f-enbase.c

+13-4
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,19 @@
486486
}
487487
}
488488

489-
if(flip==2) {
490-
// input may not be padded... see https://github.com/rebol/rebol-issues/issues/2318
491-
*bp++ = (REBYTE)(accum >> 4);
492-
} else if (flip) goto err;
489+
if (flip) {
490+
if(urlSafe) {
491+
// in url safe mode may be ommited the final inut padding
492+
if (flip == 3) {
493+
*bp++ = (REBYTE)(accum >> 10);
494+
*bp++ = (REBYTE)(accum >> 2);
495+
}
496+
else if (flip == 2) {
497+
*bp++ = (REBYTE)(accum >> 4);
498+
}
499+
else goto err;
500+
} else goto err;
501+
}
493502

494503
*bp = 0;
495504
ser->tail = bp - STR_HEAD(ser);

0 commit comments

Comments
 (0)