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
e130b702
...
e130b702f61f60addda58ef139d55401f9938143
authored
2002-11-28 15:39:32 +0000
by
Frederic Gobry
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixed quoted-printable encoder
1 parent
281d7d4e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
9 deletions
ChangeLog
mailbox/filter_trans.c
ChangeLog
View file @
e130b70
2002
-
11
-
28
Frederic
Gobry
<
frederic
.
gobry
@smartdata
.
ch
>
*
mailbox
/
filter_trans
.
c
(
qp_encode
)
:
fixed
quoted
-
printable
encoding
.
2002
-
11
-
27
Frederic
Gobry
<
frederic
.
gobry
@smartdata
.
ch
>
*
mailbox
/
filter_trans
.
c
(
trans_read
)
:
applied
patch
from
Sergey
...
...
mailbox/filter_trans.c
View file @
e130b70
...
...
@@ -456,30 +456,55 @@ qp_encode (const char *iptr, size_t isize, char *optr, size_t osize,
int
c
;
size_t
consumed
=
0
;
(
void
)
osize
;
*
nbytes
=
0
;
while
(
consumed
<
isize
&&
(
*
nbytes
+
4
)
<
isize
)
/* Strategy: check if we have enough room in the output buffer only
once the required size has been computed. If there is not enough,
return and hope that the caller will free up the output buffer a
bit. */
while
(
consumed
<
isize
)
{
if
(
*
line_len
==
QP_LINE_MAX
)
{
/* to cut a qp line requires two bytes */
if
((
*
nbytes
)
+
2
>
osize
)
return
consumed
;
*
optr
++
=
'='
;
*
optr
++
=
'\n'
;
(
*
nbytes
)
+=
2
;
*
line_len
=
0
;
}
c
=
*
iptr
++
;
consumed
++
;
if
(((
c
>=
32
)
&&
(
c
<=
60
))
||
((
c
>=
62
)
&&
(
c
<=
126
))
||
(
c
==
9
))
/* candidate byte to convert */
c
=
*
iptr
;
if
(((
c
>=
32
)
&&
(
c
<=
60
))
||
((
c
>=
62
)
&&
(
c
<=
126
))
||
(
c
==
9
))
{
/* a non-quoted character uses up one byte */
if
(
*
nbytes
+
1
>
osize
)
return
consumed
;
*
optr
++
=
c
;
(
*
nbytes
)
++
;
(
*
line_len
)
++
;
iptr
++
;
consumed
++
;
}
else
{
/* can we store the quoted character in the remaining of the
line ? */
if
(
*
line_len
>=
(
QP_LINE_MAX
-
3
))
{
/* check if we have enough room to store the padding */
if
(
*
nbytes
+
*
line_len
-
QP_LINE_MAX
+
3
>
osize
)
return
consumed
;
/* add spaces. */
while
(
*
line_len
<
QP_LINE_MAX
)
{
...
...
@@ -487,16 +512,23 @@ qp_encode (const char *iptr, size_t isize, char *optr, size_t osize,
(
*
nbytes
)
++
;
(
*
line_len
)
++
;
}
consumed
--
;
iptr
--
;
}
else
{
/* a quoted character uses up three bytes */
if
((
*
nbytes
)
+
3
>
osize
)
return
consumed
;
*
optr
++
=
'='
;
*
optr
++
=
_hexdigits
[(
c
>>
4
)
&
0xf
];
*
optr
++
=
_hexdigits
[
c
&
0xf
];
*
optr
++
=
_hexdigits
[(
c
/
16
)
&
0xf
];
(
*
nbytes
)
+=
3
;
(
*
nbytes
)
+=
3
;
(
*
line_len
)
+=
3
;
/* we've actuall used up one byte of input */
iptr
++
;
consumed
++
;
}
}
}
...
...
Please
register
or
sign in
to post a comment