Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
b308699b
Commit
b308699b
authored
Aug 09, 2011
by
Max Kanat-Alexander
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 660691: Allow Bugzilla to parse HTML-only inbound email via email_in.pl
r=glob, a=mkanat
parent
f4c7bf2d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
10 deletions
+43
-10
Requirements.pm
Bugzilla/Install/Requirements.pm
+7
-0
email_in.pl
email_in.pl
+34
-7
user-error.html.tmpl
template/en/default/global/user-error.html.tmpl
+2
-3
No files found.
Bugzilla/Install/Requirements.pm
View file @
b308699b
...
@@ -327,6 +327,13 @@ sub OPTIONAL_MODULES {
...
@@ -327,6 +327,13 @@ sub OPTIONAL_MODULES {
version
=>
0
,
version
=>
0
,
feature
=>
[
'inbound_email'
],
feature
=>
[
'inbound_email'
],
},
},
{
package
=>
'HTML-FormatText-WithLinks'
,
module
=>
'HTML::FormatText::WithLinks'
,
# We need 0.13 to set the "bold" marker to "*".
version
=>
'0.13'
,
feature
=>
[
'inbound_email'
],
},
# Mail Queueing
# Mail Queueing
{
{
...
...
email_in.pl
View file @
b308699b
...
@@ -39,6 +39,7 @@ use Email::Address;
...
@@ -39,6 +39,7 @@ use Email::Address;
use
Email::
Reply
qw(reply)
;
use
Email::
Reply
qw(reply)
;
use
Email::
MIME
;
use
Email::
MIME
;
use
Getopt::
Long
qw(:config bundling)
;
use
Getopt::
Long
qw(:config bundling)
;
use
HTML::FormatText::
WithLinks
;
use
Pod::
Usage
;
use
Pod::
Usage
;
use
Encode
;
use
Encode
;
use
Scalar::
Util
qw(blessed)
;
use
Scalar::
Util
qw(blessed)
;
...
@@ -68,6 +69,7 @@ use constant SIGNATURE_DELIMITER => '-- ';
...
@@ -68,6 +69,7 @@ use constant SIGNATURE_DELIMITER => '-- ';
use
constant
BODY_TYPES
=>
qw(
use
constant
BODY_TYPES
=>
qw(
text/plain
text/plain
text/html
text/html
application/xhtml+xml
multipart/alternative
multipart/alternative
)
;
)
;
...
@@ -321,7 +323,7 @@ sub get_body_and_attachments {
...
@@ -321,7 +323,7 @@ sub get_body_and_attachments {
# Note that this only happens if the email does not contain any
# Note that this only happens if the email does not contain any
# text/plain parts. If the email has an empty text/plain part,
# text/plain parts. If the email has an empty text/plain part,
# you're fine, and this message does NOT get thrown.
# you're fine, and this message does NOT get thrown.
ThrowUserError
(
'email_no_
text_plain
'
);
ThrowUserError
(
'email_no_
body
'
);
}
}
debug_print
(
"Picked Body:\n$body"
,
2
);
debug_print
(
"Picked Body:\n$body"
,
2
);
...
@@ -343,18 +345,43 @@ sub get_text_alternative {
...
@@ -343,18 +345,43 @@ sub get_text_alternative {
}
}
debug_print
(
"Alternative Part Content-Type: $ct"
,
2
);
debug_print
(
"Alternative Part Content-Type: $ct"
,
2
);
debug_print
(
"Alternative Part Character Encoding: $charset"
,
2
);
debug_print
(
"Alternative Part Character Encoding: $charset"
,
2
);
if
(
!
$ct
||
$ct
=~
/^text\/plain/i
)
{
# If we find a text/plain body here, return it immediately.
$body
=
$part
->
body
;
if
(
!
$ct
||
$ct
=~
m{^text/plain}i
)
{
if
(
Bugzilla
->
params
->
{
'utf8'
}
&&
!
utf8::
is_utf8
(
$body
))
{
return
_decode_body
(
$charset
,
$part
->
body
);
$body
=
Encode::
decode
(
$charset
,
$body
);
}
}
# If we find a text/html body, decode it, but don't return
last
;
# it immediately, because there might be a text/plain alternative
# later. This could be any HTML type.
if
(
$ct
=~
m{^application/xhtml\+xml}i
or
$ct
=~
m{text/html}i
)
{
my
$parser
=
HTML::FormatText::
WithLinks
->
new
(
# Put footnnote indicators after the text, not before it.
before_link
=>
''
,
after_link
=>
'[%n]'
,
# Convert bold and italics, use "*" for bold instead of "_".
with_emphasis
=>
1
,
bold_marker
=>
'*'
,
# If the same link appears multiple times, only create
# one footnote.
unique_links
=>
1
,
# If the link text is the URL, don't create a footnote.
skip_linked_urls
=>
1
,
);
$body
=
_decode_body
(
$charset
,
$part
->
body
);
$body
=
$parser
->
parse
(
$body
);
}
}
}
}
return
$body
;
return
$body
;
}
}
sub
_decode_body
{
my
(
$charset
,
$body
)
=
@_
;
if
(
Bugzilla
->
params
->
{
'utf8'
}
&&
!
utf8::
is_utf8
(
$body
))
{
return
Encode::
decode
(
$charset
,
$body
);
}
return
$body
;
}
sub
remove_leading_blank_lines
{
sub
remove_leading_blank_lines
{
my
(
$text
)
=
@_
;
my
(
$text
)
=
@_
;
$text
=~
s/^(\s*\n)+//s
;
$text
=~
s/^(\s*\n)+//s
;
...
...
template/en/default/global/user-error.html.tmpl
View file @
b308699b
...
@@ -443,9 +443,8 @@
...
@@ -443,9 +443,8 @@
[% title = "Email Address Confirmation Failed" %]
[% title = "Email Address Confirmation Failed" %]
Email address confirmation failed.
Email address confirmation failed.
[% ELSIF error == "email_no_text_plain" %]
[% ELSIF error == "email_no_body" %]
Your message did not contain any text. [% terms.Bugzilla %] does not
Your message did not contain any text, as far as we could tell.
accept HTML-only email.
[% ELSIF error == "empty_group_description" %]
[% ELSIF error == "empty_group_description" %]
[% title = "The group description can not be empty" %]
[% title = "The group description can not be empty" %]
...
...
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