diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2008-06-28 22:03:43 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2008-06-28 22:03:43 +0000 |
commit | 0f4f9f6d91f1f842f8cf6691cfcd39d34234adcd (patch) | |
tree | 14e0e49f14b0f98baf2373ac3447481ac46fb7a7 | |
parent | 130b17110dcf1f5bf42b99d06882f01545c8eb3c (diff) | |
download | libparserutils-0f4f9f6d91f1f842f8cf6691cfcd39d34234adcd.tar.gz libparserutils-0f4f9f6d91f1f842f8cf6691cfcd39d34234adcd.tar.bz2 |
Make iconv-based filtering produce correct output when encountering encoding errors.
Fix inputstream_peek_slow to flag OOD when the buffer fill routine produces no new data.
svn path=/trunk/libparserutils/; revision=4474
-rw-r--r-- | src/input/filter.c | 10 | ||||
-rw-r--r-- | src/input/inputstream.c | 3 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/input/filter.c b/src/input/filter.c index f40c98f..4a7cd7f 100644 --- a/src/input/filter.c +++ b/src/input/filter.c @@ -204,6 +204,16 @@ parserutils_error parserutils_filter_process_chunk(parserutils_filter *input, if (ret != (size_t) -1 || errno != EILSEQ) break; + if (*outlen < 3) + return PARSERUTILS_NOMEM; + + (*output)[0] = 0xef; + (*output)[1] = 0xbf; + (*output)[2] = 0xbd; + + *output += 3; + *outlen -= 3; + (*data)++; (*len)--; } diff --git a/src/input/inputstream.c b/src/input/inputstream.c index 9cbcdd2..5631331 100644 --- a/src/input/inputstream.c +++ b/src/input/inputstream.c @@ -235,7 +235,8 @@ uintptr_t parserutils_inputstream_peek_slow(parserutils_inputstream *stream, /* Refill utf8 buffer from raw buffer */ error = parserutils_inputstream_refill_buffer(s); - if (error != PARSERUTILS_OK) + if (error != PARSERUTILS_OK || + s->public.cursor + offset == s->public.utf8->length) return PARSERUTILS_INPUTSTREAM_OOD; /* Now try the read */ |