RTFTranslator: don't accept translations with no RTF involved.

Fixes #11650.
Thanks to TwoFx for investigating the issue.
This commit is contained in:
Adrien Destugues
2015-01-05 11:34:01 +01:00
parent e7cf3254ad
commit 0622135673
@@ -166,6 +166,9 @@ RTFTranslator::Identify(BPositionIO *stream,
status_t status = parser.Identify(); status_t status = parser.Identify();
if (status == B_OK) { if (status == B_OK) {
// Source data is RTF. We can translate to RTF (no-op), plaintext, or
// styled text.
// return information about the data in the stream // return information about the data in the stream
info->type = B_TRANSLATOR_TEXT; //RTF_TEXT_FORMAT; info->type = B_TRANSLATOR_TEXT; //RTF_TEXT_FORMAT;
info->group = B_TRANSLATOR_TEXT; info->group = B_TRANSLATOR_TEXT;
@@ -175,6 +178,11 @@ RTFTranslator::Identify(BPositionIO *stream,
sizeof(info->name)); sizeof(info->name));
strcpy(info->MIME, "text/rtf"); strcpy(info->MIME, "text/rtf");
} else { } else {
// Not an RTF file. We can only work with it if we are translating to
// RTF.
if (outType != RTF_TEXT_FORMAT)
return B_NO_TRANSLATOR;
stream->Seek(0, SEEK_SET); stream->Seek(0, SEEK_SET);
TranslatorStyledTextStreamHeader header; TranslatorStyledTextStreamHeader header;
stream->Read(&header, sizeof(header)); stream->Read(&header, sizeof(header));