oc-rtf: Be more resilient to spaces while parsing font tables
This avoids to crash on this example: \f0\fibi \fcharset0 -------^ Or: \f0 \fibi\fcharset0 --^ Take into account that I found lots of RTF documents with this format: \f0\fbidi \froman\fcharset0 \f0\froman\fprq2 \fcharset0 Which are not unsupported by this handler.
This commit is contained in:
parent
75ce59d010
commit
258444bb93
|
@ -573,7 +573,7 @@ const unsigned short ansicpg874[256] = {
|
||||||
// Skip our control word
|
// Skip our control word
|
||||||
if (strncmp((const char*)cw, "fonttbl", len) == 0)
|
if (strncmp((const char*)cw, "fonttbl", len) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// We must at least parse <fontnum><fontfamily><fcharset>
|
// We must at least parse <fontnum><fontfamily><fcharset>
|
||||||
s = [[NSString alloc] initWithBytesNoCopy: (void *)cw+1
|
s = [[NSString alloc] initWithBytesNoCopy: (void *)cw+1
|
||||||
length: len-1
|
length: len-1
|
||||||
|
@ -588,12 +588,18 @@ const unsigned short ansicpg874[256] = {
|
||||||
|
|
||||||
// We now parse <fontfamily><fcharset>
|
// We now parse <fontfamily><fcharset>
|
||||||
cw = [self parseControlWord: &len];
|
cw = [self parseControlWord: &len];
|
||||||
|
if (len == 0) // Possibly parsing a space
|
||||||
|
cw = [self parseControlWord: &len];
|
||||||
|
|
||||||
fontInfo->family = [[NSString alloc] initWithBytesNoCopy: (void *)cw+1
|
fontInfo->family = [[NSString alloc] initWithBytesNoCopy: (void *)cw+1
|
||||||
length: len-1
|
length: len-1
|
||||||
encoding: NSASCIIStringEncoding
|
encoding: NSASCIIStringEncoding
|
||||||
freeWhenDone: NO];
|
freeWhenDone: NO];
|
||||||
|
|
||||||
cw = [self parseControlWord: &len];
|
cw = [self parseControlWord: &len];
|
||||||
|
if (len == 0) // Possibly parsing a space
|
||||||
|
cw = [self parseControlWord: &len];
|
||||||
|
|
||||||
fontInfo->charset = [[NSString alloc] initWithBytesNoCopy: (void *)cw+1
|
fontInfo->charset = [[NSString alloc] initWithBytesNoCopy: (void *)cw+1
|
||||||
length: len-1
|
length: len-1
|
||||||
encoding: NSASCIIStringEncoding
|
encoding: NSASCIIStringEncoding
|
||||||
|
|
Loading…
Reference in a new issue