* [PATCH 0/10] various misc fixes and updates
@ 2016-07-06 7:14 5% Eric Wong
2016-07-06 7:14 7% ` [PATCH 04/10] address: attempt to handle comments somewhat Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2016-07-06 7:14 UTC (permalink / raw)
To: meta
Close to a milestone with HTML UI consistency!
Eric Wong (10):
scripts/dc-dlvr: ensure temporary files are removed
daemon: disable USR2/TTIN/TTOU/WINCH in workers
hval: get rid of unused parameter for new_msgid
address: attempt to handle comments somewhat
wwwstream: allow undef noop callback
extmsg: disable automatic inbox switching
extmsg: switch to wwwstream for partial match, too
view: fix double-escaping of ghost links
www: use HTML <hr> instead of XHTML <hr />
feed: fix links to attachments in Atom feed
lib/PublicInbox/Address.pm | 6 ++--
lib/PublicInbox/Daemon.pm | 3 +-
lib/PublicInbox/ExtMsg.pm | 73 +++++++++++++++++++++++++++---------------
lib/PublicInbox/Feed.pm | 6 ++--
lib/PublicInbox/Hval.pm | 2 +-
lib/PublicInbox/SearchView.pm | 6 ++--
lib/PublicInbox/Unsubscribe.pm | 2 +-
lib/PublicInbox/View.pm | 17 +++++-----
lib/PublicInbox/WwwStream.pm | 6 ++--
scripts/dc-dlvr | 3 +-
t/address.t | 9 ++++++
11 files changed, 84 insertions(+), 49 deletions(-)
--
EW
^ permalink raw reply [relevance 5%]
* [PATCH 04/10] address: attempt to handle comments somewhat
2016-07-06 7:14 5% [PATCH 0/10] various misc fixes and updates Eric Wong
@ 2016-07-06 7:14 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2016-07-06 7:14 UTC (permalink / raw)
To: meta
They're uncommon, fortunately, but we make no attempt to
handle nested comments (which would open us up to things
like CVE-2015-7686) or use the comment in place of a
missing name.
---
lib/PublicInbox/Address.pm | 6 ++++--
t/address.t | 9 +++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/lib/PublicInbox/Address.pm b/lib/PublicInbox/Address.pm
index e17d0b5..2c0bb04 100644
--- a/lib/PublicInbox/Address.pm
+++ b/lib/PublicInbox/Address.pm
@@ -7,7 +7,9 @@ use warnings;
# very loose regexes, here. We don't need RFC-compliance,
# just enough to make thing sanely displayable and pass to git
-sub emails { ($_[0] =~ /([\w\.\+=\-]+\@[\w\.\-]+)>?\s*(?:,\s*|\z)/g) }
+sub emails {
+ ($_[0] =~ /([\w\.\+=\-]+\@[\w\.\-]+)>?\s*(?:\(.*?\))?(?:,\s*|\z)/g)
+}
sub names {
map {
@@ -19,7 +21,7 @@ sub names {
$e = $_ =~ /\S/ ? $_ : $e;
$e =~ s/\@\S+\z//;
$e;
- } split(/\@+[\w\.\-]+>?\s*(?:,\s*|\z)/, $_[0]);
+ } split(/\@+[\w\.\-]+>?\s*(?:\(.*?\))?(?:,\s*|\z)/, $_[0]);
}
1;
diff --git a/t/address.t b/t/address.t
index 3191fed..287fcfa 100644
--- a/t/address.t
+++ b/t/address.t
@@ -20,4 +20,13 @@ is_deeply(['User', 'e', 'John A. Doe', 'x'], \@names,
@names = PublicInbox::Address::names('"user@example.com" <user@example.com>');
is_deeply(['user'], \@names, 'address-as-name extraction works as expected');
+
+{
+ my $backwards = 'u@example.com (John Q. Public)';
+ @names = PublicInbox::Address::names($backwards);
+ is_deeply(\@names, ['u'], 'backwards name OK');
+ my @emails = PublicInbox::Address::emails($backwards);
+ is_deeply(\@emails, ['u@example.com'], 'backwards emails OK');
+}
+
done_testing;
--
EW
^ permalink raw reply related [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-07-06 7:14 5% [PATCH 0/10] various misc fixes and updates Eric Wong
2016-07-06 7:14 7% ` [PATCH 04/10] address: attempt to handle comments somewhat Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).