Index: trunk/phase3/includes/Parser.php |
— | — | @@ -1858,11 +1858,15 @@ |
1859 | 1859 | return $text; |
1860 | 1860 | } |
1861 | 1861 | |
1862 | | - # Remove '<!--', '-->', and everything between. |
1863 | | - # To avoid leaving blank lines, when a comment is both preceded |
1864 | | - # and followed by a newline (ignoring spaces), trim leading and |
1865 | | - # trailing spaces and one of the newlines. |
1866 | | - /* private */ function removeHTMLcomments( $text ) { |
| 1862 | + /** |
| 1863 | + * Remove '<!--', '-->', and everything between. |
| 1864 | + * To avoid leaving blank lines, when a comment is both preceded |
| 1865 | + * and followed by a newline (ignoring spaces), trim leading and |
| 1866 | + * trailing spaces and one of the newlines. |
| 1867 | + * |
| 1868 | + * @access private |
| 1869 | + */ |
| 1870 | + function removeHTMLcomments( $text ) { |
1867 | 1871 | $fname='Parser::removeHTMLcomments'; |
1868 | 1872 | wfProfileIn( $fname ); |
1869 | 1873 | while (($start = strpos($text, '<!--')) !== false) { |
— | — | @@ -1876,9 +1880,9 @@ |
1877 | 1881 | |
1878 | 1882 | # Trim space and newline if the comment is both |
1879 | 1883 | # preceded and followed by a newline |
1880 | | - $spaceStart = $start - 1; |
| 1884 | + $spaceStart = max($start - 1, 0); |
1881 | 1885 | $spaceLen = $end - $spaceStart; |
1882 | | - while (substr($text, $spaceStart, 1) === ' ') { |
| 1886 | + while (substr($text, $spaceStart, 1) === ' ' && $spaceStart > 0) { |
1883 | 1887 | $spaceStart--; |
1884 | 1888 | $spaceLen++; |
1885 | 1889 | } |