@@ -393,7 +393,7 @@ public static string ParseRoles(string template, string userRoles)
393393
394394 const string pattern = @"\[ROLES:(.+?)\]" ;
395395
396- template = Regex . Replace ( template , pattern , delegate ( Match match )
396+ template = DotNetNuke . Common . Utilities . RegexUtils . GetCachedRegex ( pattern ) . Replace ( template , match =>
397397 {
398398 if ( userRoleArray == null || userRoleArray . Count == 0 )
399399 {
@@ -464,7 +464,7 @@ internal static string ParseProfile(DotNetNuke.Modules.ActiveForums.Entities.For
464464 var s = template ?? string . Empty ;
465465 const string pattern = "(\\ [DNN:PROFILE:(.+?)\\ ])" ;
466466
467- foreach ( Match match in Regex . Matches ( s , pattern ) )
467+ foreach ( Match match in DotNetNuke . Common . Utilities . RegexUtils . GetCachedRegex ( pattern ) . Matches ( s ) )
468468 {
469469 var sReplace = string . Empty ;
470470 var sResource = string . Empty ;
@@ -565,7 +565,7 @@ private static string ParsePreview(int portalId, string template, string message
565565 {
566566 var strHost = Common . Globals . AddHTTP ( Common . Globals . GetDomainName ( HttpContext . Current . Request ) ) + "/" ;
567567 const string pattern = "([IMAGE:(.+?)])" ;
568- foreach ( Match match in Regex . Matches ( message , pattern ) )
568+ foreach ( Match match in DotNetNuke . Common . Utilities . RegexUtils . GetCachedRegex ( pattern ) . Matches ( message ) )
569569 {
570570 var sImage = string . Format ( "<img src=\" {0}DesktopModules/ActiveForums/viewer.aspx?portalid={1}&moduleid={2}&attachid={3}\" border=\" 0\" />" , strHost , portalId , moduleId , match . Groups [ 2 ] . Value ) ;
571571 message = message . Replace ( match . Value , sImage ) ;
@@ -577,7 +577,7 @@ private static string ParsePreview(int portalId, string template, string message
577577 {
578578 var strHost = string . Concat ( Common . Globals . AddHTTP ( Common . Globals . GetDomainName ( HttpContext . Current . Request ) ) , "/" ) ;
579579 const string pattern = "([THUMBNAIL:(.+?)])" ;
580- foreach ( Match match in Regex . Matches ( message , pattern ) )
580+ foreach ( Match match in DotNetNuke . Common . Utilities . RegexUtils . GetCachedRegex ( pattern ) . Matches ( message ) )
581581 {
582582 var thumbId = match . Groups [ 2 ] . Value . Split ( ':' ) [ 0 ] ;
583583 var parentId = match . Groups [ 2 ] . Value . Split ( ':' ) [ 1 ] ;
@@ -587,16 +587,9 @@ private static string ParsePreview(int portalId, string template, string message
587587 }
588588
589589 template = template . Replace ( "[BODY]" , message ) ;
590- if ( Regex . IsMatch ( template , "<CODE([^>]*)>" , RegexOptions . IgnoreCase ) )
590+ if ( DotNetNuke . Common . Utilities . RegexUtils . GetCachedRegex ( "<CODE([^>]*)>" , RegexOptions . IgnoreCase ) . IsMatch ( template ) )
591591 {
592- if ( Regex . IsMatch ( message , "<CODE([^>]*)>" , RegexOptions . IgnoreCase ) )
593- {
594- foreach ( Match m in Regex . Matches ( message , "<CODE([^>]*)>(.*?)</CODE>" , RegexOptions . IgnoreCase ) )
595- {
596- message = message . Replace ( m . Value , m . Value . Replace ( "<br>" , System . Environment . NewLine ) ) ;
597- }
598- }
599-
592+ template = CodeParser . ReplaceBreakTagsWithNewLines ( template ) ;
600593 template = CodeParser . ParseCode ( System . Net . WebUtility . HtmlDecode ( template ) ) ;
601594 }
602595
0 commit comments