@@ -559,16 +559,19 @@ private function _translateTags(&$content, $tagsList, $formatCallback)
559
559
560
560
$ tagBodyMatch = [];
561
561
preg_match ($ tagRegExpBody , $ content , $ tagBodyMatch , PREG_OFFSET_CAPTURE );
562
- $ tagBodyOpenStartPosition = $ tagBodyMatch [0 ][1 ];
563
-
564
- if (array_key_exists ($ tagName , $ this ->_allowedTagsGlobal )
565
- && $ tagBodyOpenStartPosition > $ tagMatch [0 ][1 ]
566
- ) {
567
- $ tagHtmlHead = call_user_func ([$ this , $ formatCallback ], $ tagHtml , $ tagName , $ trArr );
568
- $ headTranslateTags .= substr ($ tagHtmlHead , strlen ($ tagHtml ));
569
- } else {
570
- $ tagHtml = call_user_func ([$ this , $ formatCallback ], $ tagHtml , $ tagName , $ trArr );
562
+ if (!empty ($ tagBodyMatch )) {
563
+ $ tagBodyOpenStartPosition = $ tagBodyMatch [0 ][1 ];
564
+
565
+ if (array_key_exists ($ tagName , $ this ->_allowedTagsGlobal )
566
+ && $ tagBodyOpenStartPosition > $ tagMatch [0 ][1 ]
567
+ ) {
568
+ $ tagHtmlHead = call_user_func ([$ this , $ formatCallback ], $ tagHtml , $ tagName , $ trArr );
569
+ $ headTranslateTags .= substr ($ tagHtmlHead , strlen ($ tagHtml ));
570
+ } else {
571
+ $ tagHtml = call_user_func ([$ this , $ formatCallback ], $ tagHtml , $ tagName , $ trArr );
572
+ }
571
573
}
574
+
572
575
$ tagClosurePos = $ tagMatch [0 ][1 ] + strlen ($ tagHtml );
573
576
$ content = substr_replace ($ content , $ tagHtml , $ tagMatch [0 ][1 ], $ tagLength );
574
577
}
0 commit comments