diff --git a/modules/png/core/chunk.scm b/modules/png/core/chunk.scm index 8304b31..43ed192 100644 --- a/modules/png/core/chunk.scm +++ b/modules/png/core/chunk.scm @@ -3,6 +3,7 @@ (define-module (png core chunk) #:use-module (oop goops) + #:use-module (ice-9 iconv) #:use-module (png core common) #:use-module (png core crc) #:use-module (srfi srfi-1) @@ -161,7 +162,10 @@ the list." (define-method (chunk-type->vector (type )) "Convert a PNG chunk TYPE to a vector. Return the vector." - (cadr (png-chunk-type-info type))) + (let ((info (png-chunk-type-info type))) + (if info + (cadr (png-chunk-type-info type)) + (string->bytevector (symbol->string type) "ASCII")))) (define-method (png-chunk-type-info (chunk )) (png-chunk-type-info (png-chunk-type chunk))) diff --git a/modules/png/fsm/chunk-context.scm b/modules/png/fsm/chunk-context.scm index 00cecf0..8abfbb6 100644 --- a/modules/png/fsm/chunk-context.scm +++ b/modules/png/fsm/chunk-context.scm @@ -1,5 +1,6 @@ (define-module (png fsm chunk-context) #:use-module (ice-9 binary-ports) + #:use-module (ice-9 iconv) #:use-module (rnrs bytevectors) #:use-module (oop goops) #:use-module (png fsm context) @@ -93,7 +94,15 @@ (action:store ctx byte) (let ((chunk (context-result ctx)) (data (context-buffer ctx))) - (png-chunk-type-set! chunk (car (vector->chunk-type data))) + (let ((type (vector->chunk-type data))) + (if type + (png-chunk-type-set! chunk (car type)) + (let ((type (string->symbol (bytevector->string data "ASCII")))) + (log-warning "action:store-type: Unknown chunk type: ~a (~a)" + data + type) + (png-chunk-type-set! chunk + type)))) (%buffer-reset! ctx (png-chunk-length chunk))) ctx)