File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,6 +75,12 @@ describe('htmlToPlainText', () => {
7575 it ( 'drops <style> and <script> contents' , ( ) => {
7676 expect ( htmlToPlainText ( '<style>p{}</style><p>Hi</p>' ) ) . toBe ( 'Hi' )
7777 } )
78+
79+ it ( 'does not double-decode compound entities like &lt;' , ( ) => {
80+ expect ( htmlToPlainText ( '<p>&lt; is the literal < entity</p>' ) ) . toBe (
81+ '< is the literal < entity'
82+ )
83+ } )
7884} )
7985
8086describe ( 'buildSimpleEmailMessage' , ( ) => {
Original file line number Diff line number Diff line change @@ -356,11 +356,11 @@ export function htmlToPlainText(html: string): string {
356356 . replace ( / < \/ ( p | d i v | h [ 1 - 6 ] | l i | t r ) > / gi, '\n' )
357357 . replace ( / < [ ^ > ] + > / g, '' )
358358 . replace ( / & n b s p ; / g, ' ' )
359- . replace ( / & a m p ; / g, '&' )
360359 . replace ( / & l t ; / g, '<' )
361360 . replace ( / & g t ; / g, '>' )
362361 . replace ( / & q u o t ; / g, '"' )
363362 . replace ( / & # 3 9 ; / g, "'" )
363+ . replace ( / & a m p ; / g, '&' )
364364 . replace ( / \n { 3 , } / g, '\n\n' )
365365 . trim ( )
366366}
You can’t perform that action at this time.
0 commit comments