зеркало из https://github.com/mozilla/pjs.git
Bug 90161 URL recognition at the end of line in QP (quoted-printable) misses last character
patch by anlan@ida.liu.se r=ducarroz sr=bienvenu
This commit is contained in:
Родитель
a524fe680f
Коммит
20d5b0540a
|
@ -52,6 +52,7 @@ static void MimeLeaf_finalize (MimeObject *);
|
|||
static int MimeLeaf_parse_begin (MimeObject *);
|
||||
static int MimeLeaf_parse_buffer (const char *, PRInt32, MimeObject *);
|
||||
static int MimeLeaf_parse_line (char *, PRInt32, MimeObject *);
|
||||
static int MimeLeaf_close_decoder (MimeObject *);
|
||||
static int MimeLeaf_parse_eof (MimeObject *, PRBool);
|
||||
static PRBool MimeLeaf_displayable_inline_p (MimeObjectClass *clazz,
|
||||
MimeHeaders *hdrs);
|
||||
|
@ -68,6 +69,7 @@ MimeLeafClassInitialize(MimeLeafClass *clazz)
|
|||
oclass->parse_line = MimeLeaf_parse_line;
|
||||
oclass->parse_eof = MimeLeaf_parse_eof;
|
||||
oclass->displayable_inline_p = MimeLeaf_displayable_inline_p;
|
||||
clazz->close_decoder = MimeLeaf_close_decoder;
|
||||
|
||||
/* Default `parse_buffer' method is one which line-buffers the now-decoded
|
||||
data and passes it on to `parse_line'. (We snarf the implementation of
|
||||
|
@ -181,6 +183,22 @@ MimeLeaf_parse_line (char *line, PRInt32 length, MimeObject *obj)
|
|||
}
|
||||
|
||||
|
||||
static int
|
||||
MimeLeaf_close_decoder (MimeObject *obj)
|
||||
{
|
||||
MimeLeaf *leaf = (MimeLeaf *) obj;
|
||||
|
||||
if (leaf->decoder_data)
|
||||
{
|
||||
int status = MimeDecoderDestroy(leaf->decoder_data, PR_FALSE);
|
||||
leaf->decoder_data = 0;
|
||||
return status;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
MimeLeaf_parse_eof (MimeObject *obj, PRBool abort_p)
|
||||
{
|
||||
|
@ -191,11 +209,10 @@ MimeLeaf_parse_eof (MimeObject *obj, PRBool abort_p)
|
|||
it is still holding.
|
||||
*/
|
||||
if (leaf->decoder_data)
|
||||
{
|
||||
int status = MimeDecoderDestroy(leaf->decoder_data, PR_FALSE);
|
||||
leaf->decoder_data = 0;
|
||||
if (status < 0) return status;
|
||||
}
|
||||
{
|
||||
int status = MimeLeaf_close_decoder(obj);
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
/* Now run the superclass's parse_eof, which will force out the line
|
||||
buffer (which we may have just repopulated, above.)
|
||||
|
|
|
@ -67,6 +67,7 @@ struct MimeLeafClass {
|
|||
MimeObjectClass object;
|
||||
/* This is the callback that is handed to the decoder. */
|
||||
int (*parse_decoded_buffer) (const char *buf, PRInt32 size, MimeObject *obj);
|
||||
int (*close_decoder) (MimeObject *obj);
|
||||
};
|
||||
|
||||
extern MimeLeafClass mimeLeafClass;
|
||||
|
|
|
@ -231,14 +231,17 @@ MimeInlineText_parse_eof (MimeObject *obj, PRBool abort_p)
|
|||
|
||||
MimeInlineText *text = (MimeInlineText *) obj;
|
||||
|
||||
/* If there is still data in the ibuffer, that means that the last line of
|
||||
this part didn't end in a newline; so push it out anyway (this means that
|
||||
the parse_line method will be called with a string with no trailing
|
||||
newline, which isn't the usual case.) We do this here, rather than in
|
||||
MimeObject_parse_eof, because MimeObject likes to shove things through
|
||||
parse_line, and we have to shove it through the magic rotating-and-converting
|
||||
code. So, we do that and digest the buffer before MimeObject has a chance
|
||||
to do the wrong thing. See bug #26276 for more painful details.
|
||||
/* Flush any buffered data from the MimeLeaf's decoder */
|
||||
status = ((MimeLeafClass*)&MIME_SUPERCLASS)->close_decoder(obj);
|
||||
if (status < 0) return status;
|
||||
|
||||
/* If there is still data in the ibuffer, that means that the last
|
||||
line of this part didn't end in a newline; so push it out anyway
|
||||
(this means that the parse_line method will be called with a string
|
||||
with no trailing newline, which isn't the usual case). We do this
|
||||
here, rather than in MimeObject_parse_eof, because MimeObject isn't
|
||||
aware of the rotating-and-converting / charset detection we need to
|
||||
do first.
|
||||
*/
|
||||
if (!abort_p && obj->ibuffer_fp > 0)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче