diff --git a/lib/modules/Tools.pmod/_PEM.pmod b/lib/modules/Tools.pmod/_PEM.pmod index 96adbf9387e398996798bacfc71d2df316d9f5ce..b17c979677b9131ed447a6d55f724c42fc273e66 100644 --- a/lib/modules/Tools.pmod/_PEM.pmod +++ b/lib/modules/Tools.pmod/_PEM.pmod @@ -10,9 +10,13 @@ object rfc822_start_re = Regexp("^([-a-zA-Z][a-zA-Z0-9]*[ \t]*:|[ \t]*\n\n)"); /* Regexp used to extract the interesting part of an encapsulation * boundary. Also strips spaces, and requires that the string in the - * middle between ---foo --- is at least two characters long. */ + * middle between ---foo --- is at least two characters long. Also + * allow a trailing \r or other white space characters. */ -object rfc934_eb_re = Regexp("^-*[ \t]*([^- \t].*[^- \t])[ \t]*-*$"); +object rfc934_eb_re = Regexp( + "^-*[ \r\t]*([^- \r\t]" /* First non dash-or-space character */ + ".*[^- \r\t])" /* Last non dash-or-space character */ + "[ \r\t]*-*[ \r\t]*$"); /* Trailing space, dashes and space */ /* Start and end markers for PEM */ @@ -44,6 +48,15 @@ string dash_stuff(string msg) return parts * "- -"; } +#if 0 +string chop_cr(string s) +{ + return (strlen(s) && (s[-1] == '\r')) + ? s[..strlen(s) - 2] + : s; +} +#endif + /* Strip dashes */ string extract_boundary(string s) {