Bugfix: produce valid XHTML even if user entered invalid '' / ''' mark-up.
authorArne Heizmann <timwi@users.mediawiki.org>
Sat, 7 Aug 2004 12:37:20 +0000 (12:37 +0000)
committerArne Heizmann <timwi@users.mediawiki.org>
Sat, 7 Aug 2004 12:37:20 +0000 (12:37 +0000)
includes/Parser.php

index 8a9ee6a..a0e8649 100644 (file)
@@ -923,9 +923,9 @@ class Parser
                                                $arr[$i] = "'''''";
                                        }
                                        # Count the number of occurrences of bold and italics mark-ups.
+                                       # We are not counting sequences of five apostrophes.
                                        if (strlen ($arr[$i]) == 2) $numitalics++;  else
-                                       if (strlen ($arr[$i]) == 3) $numbold++;     else
-                                       if (strlen ($arr[$i]) == 5) { $numitalics++; $numbold++; }
+                                       if (strlen ($arr[$i]) == 3) $numbold++;
                                }
                                $i++;
                        }
@@ -1037,6 +1037,15 @@ class Parser
                                }
                                $i++;
                        }
+                       # Now close all remaining tags.  Notice that the order is important.
+                       if ($state == 'strong' || $state == 'emstrong')
+                               $output .= "</strong>";
+                       if ($state == 'em' || $state == 'strongem' || $state == 'emstrong')
+                               $output .= "</em>";
+                       if ($state == 'strongem')
+                               $output .= "</strong>";
+                       if ($state == 'both')
+                               $output .= "<strong><em>{$buffer}</em></strong>";
                        return $output;
                }
        }