Skip to content

Commit

Permalink
Backported CORE-2122: Translation of large text BLOB between UNICODE_…
Browse files Browse the repository at this point in the history
…FSS (UTF8) and other charsets.
  • Loading branch information
dyemanov committed Jul 7, 2010
1 parent 8fa0fad commit e1cb23f
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/jrd/filters.cpp
Expand Up @@ -909,7 +909,7 @@ ISC_STATUS filter_transliterate_text(USHORT action, BlobControl* control)
/* Always keep a minimal count of bytes in the input buffer,
* to prevent the case of truncated characters.
*/
if (length < 3)
if (length < 4)
can_use_more = true;
}

Expand All @@ -920,13 +920,14 @@ ISC_STATUS filter_transliterate_text(USHORT action, BlobControl* control)
(We don't want to blindly keep topping off this buffer if we
already have more than we can use) */

if (!length || can_use_more
&& (aux->ctlaux_source_blob_status == isc_segment))
USHORT bytes_read_from_source = 0;

if (!length || can_use_more)
// && (aux->ctlaux_source_blob_status == isc_segment))
{
// Get a segment, or partial segment, from the source
// into the temporary buffer

USHORT bytes_read_from_source = 0;
status = caller(isc_blob_filter_get_segment,
control,
(USHORT) MIN((aux->ctlaux_buffer1_len - length), control->ctl_buffer_length),
Expand Down Expand Up @@ -960,10 +961,17 @@ ISC_STATUS filter_transliterate_text(USHORT action, BlobControl* control)
return isc_transliteration_failed;
}

if (err_position < length) {
/* Bad input *might* be due to input buffer truncation in the middle
of a character, so shuffle bytes, add some more data, and try again.
If we already tried that then it's really some bad input */
if (err_position == 0 && bytes_read_from_source != 0 && length != 0 && length < 4) {
// We don't have sufficient bytes to always transliterate a character.
// A bad input on the first character is unrecoverable, so we cache
// the bytes for the next read.
result_length = 0;
}
else if (err_position < length)
{
// Bad input *might* be due to input buffer truncation in the middle
// of a character, so shuffle bytes, add some more data, and try again.
// If we already tried that then it's really some bad input.

if (err_position == 0)
return isc_transliteration_failed;
Expand Down

0 comments on commit e1cb23f

Please sign in to comment.