Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
e0686b2d
...
e0686b2d7732e49cd72e5f8ca82a220a54ed3d38
authored
2003-09-25 14:04:15 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
(rfc2047_decode): Ignore whitespace between the encoded segments.
1 parent
bcbac517
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
16 deletions
mailbox/rfc2047.c
mailbox/rfc2047.c
View file @
e0686b2
...
...
@@ -36,6 +36,7 @@ rfc2047_decode (const char *tocode, const char *input, char **ptostr)
char
*
buffer
;
size_t
bufsize
;
size_t
bufpos
;
size_t
run_count
=
0
;
if
(
!
tocode
||
!
input
||
!
ptostr
)
return
EINVAL
;
...
...
@@ -61,6 +62,8 @@ rfc2047_decode (const char *tocode, const char *input, char **ptostr)
while
(
*
fromstr
)
{
if
(
strncmp
(
fromstr
,
"=?"
,
2
)
==
0
)
{
char
*
fromcode
=
NULL
;
char
*
encoding_type
=
NULL
;
char
*
encoded_text
=
NULL
;
...
...
@@ -70,20 +73,7 @@ rfc2047_decode (const char *tocode, const char *input, char **ptostr)
size_t
nbytes
=
0
,
size
;
char
*
sp
=
NULL
;
start_position
=
strstr
(
fromstr
,
"=?"
);
if
(
!
start_position
)
break
;
/* Copy the unencoded part */
nbytes
=
start_position
-
fromstr
;
if
(
bufpos
+
nbytes
>
bufsize
)
/* just in case */
{
status
=
MU_ERR_BAD_2047_INPUT
;
break
;
}
memcpy
(
buffer
+
bufpos
,
fromstr
,
nbytes
);
bufpos
+=
nbytes
;
start_position
=
fromstr
;
fromcode
=
strtok_r
(
start_position
+
2
,
"?"
,
&
sp
);
encoding_type
=
strtok_r
(
NULL
,
"?"
,
&
sp
);
...
...
@@ -94,7 +84,9 @@ rfc2047_decode (const char *tocode, const char *input, char **ptostr)
break
;
}
if
(
fromcode
==
NULL
||
encoding_type
==
NULL
||
encoded_text
==
NULL
)
if
(
fromcode
==
NULL
||
encoding_type
==
NULL
||
encoded_text
==
NULL
)
{
status
=
MU_ERR_BAD_2047_INPUT
;
break
;
...
...
@@ -125,7 +117,8 @@ rfc2047_decode (const char *tocode, const char *input, char **ptostr)
filter_create
(
&
filter
,
in_stream
,
filter_type
,
MU_FILTER_DECODE
,
MU_STREAM_READ
);
while
(
stream_sequential_read
(
filter
,
buffer
+
bufpos
,
bufsize
-
bufpos
,
while
(
stream_sequential_read
(
filter
,
buffer
+
bufpos
,
bufsize
-
bufpos
,
&
nbytes
)
==
0
&&
nbytes
)
{
/* FIXME: Need to convert character set */
...
...
@@ -136,6 +129,30 @@ rfc2047_decode (const char *tocode, const char *input, char **ptostr)
stream_destroy
(
&
filter
,
stream_get_owner
(
filter
));
fromstr
=
sp
+
1
;
run_count
=
1
;
}
else
if
(
run_count
)
{
if
(
*
fromstr
==
' '
||
*
fromstr
==
'\t'
)
{
run_count
++
;
fromstr
++
;
continue
;
}
else
{
if
(
--
run_count
)
{
memcpy
(
buffer
+
bufpos
,
fromstr
-
run_count
,
run_count
);
bufpos
+=
run_count
;
run_count
=
0
;
}
buffer
[
bufpos
++
]
=
*
fromstr
++
;
}
}
else
buffer
[
bufpos
++
]
=
*
fromstr
++
;
}
if
(
*
fromstr
)
...
...
Please
register
or
sign in
to post a comment