+2007-04-04 Jackson Harper <jackson@ximian.com>
+
+ * RTF.cs: look ahead for the end of the group, so we don't read
+ past the end and pull out a piece of the next token.
+
2007-04-04 Jackson Harper <jackson@ximian.com>
* Picture.cs: Correct twips calculation.
/// <summary>Parse the RTF stream</summary>
public void Read() {
while (GetToken() != TokenClass.EOF) {
-
RouteToken();
}
}
while (true) {
- while (hexDigit1 == '\n' || hexDigit1 == '\r')
+ while (hexDigit1 == '\n' || hexDigit1 == '\r') {
+ hexDigit1 = (char) source.Peek ();
+ if (hexDigit1 == '}')
+ break;
hexDigit1 = (char) source.Read ();
-
+ }
+
+ hexDigit2 = (char) source.Peek ();
+ if (hexDigit2 == '}')
+ break;
hexDigit2 = (char) source.Read ();
- while (hexDigit2 == '\n' || hexDigit2 == '\r')
+ while (hexDigit2 == '\n' || hexDigit2 == '\r') {
+ hexDigit2 = (char) source.Peek ();
+ if (hexDigit2 == '}')
+ break;
hexDigit2 = (char) source.Read ();
+ }
if (Char.IsDigit (hexDigit1))
digitValue1 = (uint) (hexDigit1 - '0');
digitValue2 = (uint) (hexDigit2 - 'A' + 10);
else if (hexDigit2 == '\n' || hexDigit2 == '\r')
continue;
- else
+ else
break;
image_data.Add ((byte) checked (digitValue1 * 16 + digitValue2));
// We get the first hex digit at the end, since in the very first
// iteration we use rtf.major as the first hex digit
+ hexDigit1 = (char) source.Peek ();
+ if (hexDigit1 == '}')
+ break;
hexDigit1 = (char) source.Read ();
}
+
read_image_data = false;
picture.Data = (byte []) image_data.ToArray (typeof (byte));
break;