Skip to content

Commit 7b9e655

Browse files
committed
FIX: simple text (and empty text) should be identified as TEXT when using ENCODING? function.
Note: MARKUP type is now never identified as it would require more advanced identification.
1 parent f0ab71b commit 7b9e655

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

src/core/b-init.c

+1
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ extern const REBYTE Str_Banner[];
685685
codi->error = 0;
686686

687687
if (codi->action == CODI_IDENTIFY) {
688+
codi->error = 1; // never identified... would require markup validator
688689
return CODI_CHECK; // error code is inverted result
689690
}
690691

src/core/n-system.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ char *evoke_help = "Evoke values:\n"
407407
if (VAL_HANDLE_TYPE(hnd) != SYM_CODEC) Trap0(RE_INVALID_HANDLE);
408408

409409
CLEAR(&codi, sizeof(codi));
410+
codi.action = CODI_DECODE;
410411

411412
val = D_ARG(3);
412413

@@ -416,7 +417,6 @@ char *evoke_help = "Evoke values:\n"
416417
codi.action = CODI_IDENTIFY;
417418
case SYM_DECODE:
418419
if (!IS_BINARY(val)) Trap1(RE_INVALID_ARG, val);
419-
codi.action = CODI_DECODE;
420420
codi.data = VAL_BIN_DATA(D_ARG(3));
421421
codi.len = VAL_LEN(D_ARG(3));
422422
break;

src/mezz/codec-gzip.r

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ register-codec [
2020
]
2121

2222
identify: function [data [binary!]][
23+
if 10 > length? data [return none]
2324
if verbose > 0 [
2425
print ["^[[1;32mDecode GZIP data^[[m (^[[1m" length? data "^[[mbytes )"]
2526
]

src/tests/units/codecs-test.r3

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ Rebol [
88

99
~~~start-file~~~ "Codecs"
1010

11+
===start-group=== "Codec's identify"
12+
--test-- "encoding?"
13+
--assert 'text = encoding? #{}
14+
--assert 'text = encoding? #{6162}
15+
===end-group===
16+
1117
if find system/codecs 'wav [
1218
system/codecs/wav/verbose: 3
1319
===start-group=== "WAV codec"

0 commit comments

Comments
 (0)