File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -399,6 +399,8 @@ Env.applyBbCodeToHtml = function(htmlToParse) {
399399
400400 var tagName ;
401401
402+ htmlToParse = htmlToParse . replace ( '\n' , '<br>' ) ;
403+
402404 while ( htmlToParse ) {
403405 var currentPattern = allStartTagsPattern ;
404406 if ( tagStack . length !== 0 ) {
@@ -587,6 +589,8 @@ Env.removeBbCodeFromHtml = function(htmlToParse) {
587589
588590 var tagName ;
589591
592+ htmlToParse = htmlToParse . replace ( '\n' , ' ' ) ;
593+
590594 while ( htmlToParse ) {
591595 var currentPattern = allStartTagsPattern ;
592596 if ( tagStack . length !== 0 ) {
@@ -603,7 +607,7 @@ Env.removeBbCodeFromHtml = function(htmlToParse) {
603607 // to end at the first [/quote], not the second)
604608 currentPattern = '^(.*?)(?:' + currentPattern + ')(.*)$' ;
605609 // case-insensitive, multi-line
606- var regExp = new RegExp ( currentPattern , 'im ' ) ;
610+ var regExp = new RegExp ( currentPattern , 'ims ' ) ;
607611
608612 var match = htmlToParse . match ( regExp ) ;
609613 if ( match ) {
Original file line number Diff line number Diff line change @@ -270,12 +270,24 @@ test("test_Env.applyBbCodeToHtml", function(assert) {
270270 holder . append ( Env . applyBbCodeToHtml ( rawHtml ) ) ;
271271 assert . ok ( holder . find ( 'b' ) . length == 1 , '<b> tag *should* be allowed unmolested' ) ;
272272 assert . ok ( holder . find ( '.chatItalic' ) . length == 1 , '[i] tag should be converted to HTML' ) ;
273+
274+ rawHtml = '[u]aaaa[/u]cc\ndd[u]bbbb[/u]' ;
275+ var newHtml = Env . applyBbCodeToHtml ( rawHtml ) ;
276+ assert . equal (
277+ newHtml ,
278+ '<span class="chatUnderlined">aaaa</span>cc<br>dd<span class="chatUnderlined">bbbb</span>' ,
279+ 'New HTML should be correct'
280+ ) ;
273281} ) ;
274282
275283test ( "test_Env.removeBbCodeFromHtml" , function ( assert ) {
276284 var rawHtml = '<b>HTML</b><br/>[i]BB Code[/i]' ;
277285 var newHtml = Env . removeBbCodeFromHtml ( rawHtml ) ;
278286 assert . equal ( newHtml , '<b>HTML</b><br/>BB Code' , 'Stripped-down HTML should be correct' ) ;
287+
288+ rawHtml = '[u]aaaa[/u]cc\ndd[u]bbbb[/u]' ;
289+ newHtml = Env . removeBbCodeFromHtml ( rawHtml ) ;
290+ assert . equal ( newHtml , 'aaaacc ddbbbb' , 'Stripped-down HTML should be correct' ) ;
279291} ) ;
280292
281293test ( "test_Env.escapeRegexp" , function ( assert ) {
You can’t perform that action at this time.
0 commit comments