Commit d33d7ec 1 parent da665c8 commit d33d7ec Copy full SHA for d33d7ec
File tree 2 files changed +31
-0
lines changed
2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -797,6 +797,10 @@ class MailParser extends Transform {
797
797
}
798
798
} ) ;
799
799
this . emit ( 'headers' , node . headers ) ;
800
+
801
+ if ( node . headerLines ) {
802
+ this . emit ( 'headerLines' , node . headerLines ) ;
803
+ }
800
804
}
801
805
802
806
if ( data . contentType === 'message/rfc822' && data . messageNode ) {
Original file line number Diff line number Diff line change @@ -141,6 +141,33 @@ exports['General tests'] = {
141
141
} ) ;
142
142
} ,
143
143
144
+ 'HeaderLines event' : test => {
145
+ let encodedText = 'X-Test: =?UTF-8?Q?=C3=95=C3=84?= =?UTF-8?Q?=C3=96=C3=9C?=\r\n' + 'Subject: ABCDEF' ,
146
+ mail = Buffer . from ( encodedText , 'utf-8' ) ;
147
+
148
+ test . expect ( 3 ) ;
149
+ let mailparser = new MailParser ( ) ;
150
+
151
+ mailparser . on ( 'headerLines' , headerLines => {
152
+ test . equal ( ! ! headerLines . find ( ( { line } ) => line === 'X-Test: =?UTF-8?Q?=C3=95=C3=84?= =?UTF-8?Q?=C3=96=C3=9C?=' ) , true ) ;
153
+ test . equal ( ! ! headerLines . find ( ( { line } ) => line === 'Subject: ABCDEF' ) , true ) ;
154
+ } ) ;
155
+
156
+ mailparser . end ( mail ) ;
157
+ mailparser . on ( 'data' , data => {
158
+ if ( data && data . release ) {
159
+ data . content . on ( 'data' , ( ) => false ) ;
160
+ data . content . on ( 'end' , ( ) => false ) ;
161
+ data . release ( ) ;
162
+ }
163
+ } ) ;
164
+
165
+ mailparser . on ( 'end' , ( ) => {
166
+ test . ok ( 1 , 'Parsing ended' ) ;
167
+ test . done ( ) ;
168
+ } ) ;
169
+ } ,
170
+
144
171
'No priority' : test => {
145
172
let encodedText = 'Content-type: text/plain; charset=utf-8\r\nSubject: ÕÄÖÜ\n\r\n1234' ,
146
173
mail = Buffer . from ( encodedText , 'utf-8' ) ;
You can’t perform that action at this time.
0 commit comments