Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
0672bfa2
Commit
0672bfa2
authored
Feb 01, 2017
by
Jacek Caban
Committed by
Alexandre Julliard
Feb 01, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inetcomm: Added support for decoding quoted-printable data.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
07af9d0d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
3 deletions
+108
-3
mimeole.c
dlls/inetcomm/mimeole.c
+94
-3
mimeole.c
dlls/inetcomm/tests/mimeole.c
+14
-0
No files found.
dlls/inetcomm/mimeole.c
View file @
0672bfa2
...
...
@@ -1614,6 +1614,90 @@ static HRESULT decode_base64(IStream *input, IStream **ret_stream)
return
S_OK
;
}
static
int
hex_digit
(
char
c
)
{
if
(
'0'
<=
c
&&
c
<=
'9'
)
return
c
-
'0'
;
if
(
'A'
<=
c
&&
c
<=
'F'
)
return
c
-
'A'
+
10
;
if
(
'a'
<=
c
&&
c
<=
'f'
)
return
c
-
'a'
+
10
;
return
-
1
;
}
static
HRESULT
decode_qp
(
IStream
*
input
,
IStream
**
ret_stream
)
{
const
unsigned
char
*
ptr
,
*
end
;
unsigned
char
*
ret
,
prev
=
0
;
unsigned
char
buf
[
1024
];
LARGE_INTEGER
pos
;
IStream
*
output
;
DWORD
size
;
int
n
=
-
1
;
HRESULT
hres
;
pos
.
QuadPart
=
0
;
hres
=
IStream_Seek
(
input
,
pos
,
STREAM_SEEK_SET
,
NULL
);
if
(
FAILED
(
hres
))
return
hres
;
hres
=
CreateStreamOnHGlobal
(
NULL
,
TRUE
,
&
output
);
if
(
FAILED
(
hres
))
return
hres
;
while
(
1
)
{
hres
=
IStream_Read
(
input
,
buf
,
sizeof
(
buf
),
&
size
);
if
(
FAILED
(
hres
)
||
!
size
)
break
;
ptr
=
ret
=
buf
;
end
=
buf
+
size
;
while
(
ptr
<
end
)
{
unsigned
char
byte
=
*
ptr
++
;
switch
(
n
)
{
case
-
1
:
if
(
byte
==
'='
)
n
=
0
;
else
*
ret
++
=
byte
;
continue
;
case
0
:
prev
=
byte
;
n
=
1
;
continue
;
case
1
:
if
(
prev
!=
'\r'
||
byte
!=
'\n'
)
{
int
h1
=
hex_digit
(
prev
),
h2
=
hex_digit
(
byte
);
if
(
h1
!=
-
1
&&
h2
!=
-
1
)
*
ret
++
=
(
h1
<<
4
)
|
h2
;
else
*
ret
++
=
'='
;
}
n
=
-
1
;
continue
;
}
}
if
(
ret
>
buf
)
{
hres
=
IStream_Write
(
output
,
buf
,
ret
-
buf
,
NULL
);
if
(
FAILED
(
hres
))
break
;
}
}
if
(
SUCCEEDED
(
hres
))
hres
=
IStream_Seek
(
output
,
pos
,
STREAM_SEEK_SET
,
NULL
);
if
(
FAILED
(
hres
))
{
IStream_Release
(
output
);
return
hres
;
}
*
ret_stream
=
output
;
return
S_OK
;
}
static
HRESULT
WINAPI
MimeBody_GetData
(
IMimeBody
*
iface
,
ENCODINGTYPE
ietEncoding
,
...
...
@@ -1628,12 +1712,19 @@ static HRESULT WINAPI MimeBody_GetData(
if
(
This
->
encoding
!=
ietEncoding
)
{
switch
(
This
->
encoding
)
{
case
IET_BASE64
:
if
(
ietEncoding
!=
IET_BINARY
)
FIXME
(
"Encofing %d is not supported.
\n
"
,
ietEncoding
);
return
decode_base64
(
This
->
data
,
ppStream
);
hres
=
decode_base64
(
This
->
data
,
ppStream
);
break
;
case
IET_QP
:
hres
=
decode_qp
(
This
->
data
,
ppStream
);
break
;
default:
FIXME
(
"Decoding %d is not supported.
\n
"
,
This
->
encoding
);
hres
=
S_FALSE
;
}
if
(
ietEncoding
!=
IET_BINARY
)
FIXME
(
"Encoding %d is not supported.
\n
"
,
ietEncoding
);
if
(
hres
!=
S_FALSE
)
return
hres
;
}
start
.
QuadPart
=
0
;
...
...
dlls/inetcomm/tests/mimeole.c
View file @
0672bfa2
...
...
@@ -556,6 +556,20 @@ static void test_SetData(void)
test_stream_read
(
stream
,
S_OK
,
"
\t\r
"
,
3
);
IStream_Release
(
stream
);
stream
=
create_stream_from_string
(
" =3d=3D
\"
one
\"
\t
=
\r\n
tw= o=
\n
x3
\n
=34
\r\n
5"
);
hr
=
IMimeBody_SetData
(
body
,
IET_QP
,
"text"
,
"plain"
,
&
IID_IStream
,
stream
);
IStream_Release
(
stream
);
ok
(
hr
==
S_OK
,
"SetData failed: %08x
\n
"
,
hr
);
test_current_encoding
(
body
,
IET_QP
);
hr
=
IMimeBody_GetData
(
body
,
IET_BINARY
,
&
stream
);
ok
(
hr
==
S_OK
,
"GetData failed %08x
\n
"
,
hr
);
test_stream_read
(
stream
,
S_OK
,
" ==
\"
one
\"
\t
tw=o=3
\n
4
\r\n
5"
,
-
1
);
IStream_Release
(
stream
);
IMimeBody_Release
(
body
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment