diff --git a/lib/Parser.js b/lib/Parser.js index a1a370c..52a877b 100644 --- a/lib/Parser.js +++ b/lib/Parser.js @@ -20,9 +20,9 @@ var CH_LF = 10, RE_CONTINUE = /^\+(?: (?:\[([^\]]+)\] )?(.+))?$/i, RE_CRLF = /\r\n/g, RE_HDR = /^([^:]+):[ \t]?(.+)?$/, - RE_ENCWORD = /=\?([^?]*?)\?([qb])\?(.*?)\?=/gi, - RE_ENCWORD_END = /=\?([^?]*?)\?([qb])\?(.*?)\?=$/i, - RE_ENCWORD_BEGIN = /^[ \t]=\?([^?]*?)\?([qb])\?(.*?)\?=/i, + RE_ENCWORD = /=\?([^?*]*?)(?:\*.*?)?\?([qb])\?(.*?)\?=/gi, + RE_ENCWORD_END = /=\?([^?*]*?)(?:\*.*?)?\?([qb])\?(.*?)\?=$/i, + RE_ENCWORD_BEGIN = /^[ \t]=\?([^?*]*?)(?:\*.*?)?\?([qb])\?(.*?)\?=/i, RE_QENC = /(?:=([a-fA-F0-9]{2}))|_/g, RE_SEARCH_MODSEQ = /^(.+) \(MODSEQ (.+?)\)$/i, RE_LWS_ONLY = /^[ \t]*$/; diff --git a/test/test-parse-header.js b/test/test-parse-header.js index 2109599..5b879db 100644 --- a/test/test-parse-header.js +++ b/test/test-parse-header.js @@ -20,6 +20,14 @@ var CRLF = '\r\n'; expected: { subject: [ '¡Hola, señor!' ] }, what: 'MIME encoded-word in value' }, + { source: ['Subject: =?iso-8859-1*es?Q?=A1Hola,_se=F1or!?=', CRLF], + expected: { subject: [ '¡Hola, señor!' ] }, + what: 'MIME encoded-word in value with language set (RFC2231)' + }, + { source: ['Subject: =?iso-8859-1*?Q?=A1Hola,_se=F1or!?=', CRLF], + expected: { subject: [ '¡Hola, señor!' ] }, + what: 'MIME encoded-word in value with empty language set' + }, { source: ['Subject: =?GB2312?Q?=B2=E2=CA=D4=CC=E2=C4=BF=D3=EB=D6=D0=B9=FA=D0=C5_long_subjects_are_not_OK_12?=', CRLF, ' =?GB2312?Q?345678901234567890123456789012345678901234567890123456789012?=', CRLF, ' =?GB2312?Q?345678901234567890?=', CRLF],