From: Sam H. v. a. <we...@ma...> - 2005-12-05 17:52:38
|
Log Message: ----------- added proper phrase quoting to rfc822_mailbox -- fixes bug #875. Modified Files: -------------- webwork2/lib/WeBWorK/DB/Record: User.pm Revision Data ------------- Index: User.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/DB/Record/User.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -Llib/WeBWorK/DB/Record/User.pm -Llib/WeBWorK/DB/Record/User.pm -u -r1.7 -r1.8 --- lib/WeBWorK/DB/Record/User.pm +++ lib/WeBWorK/DB/Record/User.pm @@ -82,6 +82,31 @@ } } +# mailbox = addr-spec ; simple address +# / phrase route-addr ; name & addr-spec +# route-addr = "<" [route] addr-spec ">" +# addr-spec = local-part "@" domain ; global address +# phrase = 1*word ; Sequence of words +# word = atom / quoted-string +# atom = 1*<any CHAR except specials, SPACE and CTLs> +# specials = "(" / ")" / "<" / ">" / "@" ; Must be in quoted- +# / "," / ";" / ":" / "\" / <"> ; string, to use +# / "." / "[" / "]" ; within a word. +# CR = <ASCII CR, carriage return> ; ( 15, 13.) +# CTL = <any ASCII control ; ( 0- 37, 0.- 31.) +# character and DEL> ; ( 177, 127.) +# SPACE = <ASCII SP, space> ; ( 40, 32.) +# HTAB = <ASCII HT, horizontal-tab> ; ( 11, 9.) +# quoted-string = <"> *(qtext/quoted-pair) <">; Regular qtext or +# ; quoted chars. +# qtext = <any CHAR excepting <">, ; => may be folded +# "\" & CR, and including +# linear-white-space> +# linear-white-space = 1*([CRLF] LWSP-char) ; semantics = SPACE +# ; CRLF => folding +# LWSP-char = SPACE / HTAB ; semantics = SPACE +# quoted-pair = "\" CHAR ; may quote any char + sub rfc822_mailbox { my ($self) = @_; @@ -90,6 +115,12 @@ if (defined $address and $address ne "") { if (defined $full_name and $full_name ne "") { + # see if we need to quote the phrase + # (this regex matches CTL, SPACE, and specials) + if ($full_name =~ /[\0-\037\177 ()<>@,;:\\".\[\]]/) { + $full_name =~ s/(["\\\r])/\\$1/g; # escape <">, "\", or CR + $full_name = "\"$full_name\""; + } return "$full_name <$address>"; } else { return $address; |