Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
63639dd2
Commit
63639dd2
authored
Jun 10, 2011
by
David Symonds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mail: decode RFC 2047-encoded words, not phrases.
R=rsc, r, bradfitz CC=golang-dev
https://golang.org/cl/4590047
parent
1fddbab7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
5 deletions
+16
-5
src/pkg/mail/message.go
src/pkg/mail/message.go
+6
-5
src/pkg/mail/message_test.go
src/pkg/mail/message_test.go
+10
-0
No files found.
src/pkg/mail/message.go
View file @
63639dd2
...
...
@@ -330,6 +330,12 @@ func (p *addrParser) consumePhrase() (phrase string, err os.Error) {
// atom
word
,
err
=
p
.
consumeAtom
(
false
)
}
// RFC 2047 encoded-word starts with =?, ends with ?=, and has two other ?s.
if
err
==
nil
&&
strings
.
HasPrefix
(
word
,
"=?"
)
&&
strings
.
HasSuffix
(
word
,
"?="
)
&&
strings
.
Count
(
word
,
"?"
)
==
4
{
word
,
err
=
decodeRFC2047Word
(
word
)
}
if
err
!=
nil
{
break
}
...
...
@@ -342,11 +348,6 @@ func (p *addrParser) consumePhrase() (phrase string, err os.Error) {
return
""
,
os
.
ErrorString
(
"mail: missing word in phrase"
)
}
phrase
=
strings
.
Join
(
words
,
" "
)
// RFC 2047 encoded-word starts with =?, ends with ?=, and has two other ?s.
if
strings
.
HasPrefix
(
phrase
,
"=?"
)
&&
strings
.
HasSuffix
(
phrase
,
"?="
)
&&
strings
.
Count
(
phrase
,
"?"
)
==
4
{
return
decodeRFC2047Word
(
phrase
)
}
return
phrase
,
nil
}
...
...
src/pkg/mail/message_test.go
View file @
63639dd2
...
...
@@ -207,6 +207,16 @@ func TestAddressParsing(t *testing.T) {
},
},
},
// RFC 2047, Section 8.
{
`=?ISO-8859-1?Q?Andr=E9?= Pirard <PIRARD@vm1.ulg.ac.be>`
,
[]
*
Address
{
&
Address
{
Name
:
`André Pirard`
,
Address
:
"PIRARD@vm1.ulg.ac.be"
,
},
},
},
}
for
_
,
test
:=
range
tests
{
addrs
,
err
:=
newAddrParser
(
test
.
addrsStr
)
.
parseAddressList
()
...
...
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