From: Erik Moeller Date: Tue, 24 Aug 2004 18:04:37 +0000 (+0000) Subject: do not parse malformed sections for section editing (fix bug #186) X-Git-Tag: 1.5.0alpha1~2237 X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_add%27%29%20%7D%7D?a=commitdiff_plain;h=f67b9ac43b46418f1f8b2516adae2583e217fb8f;p=lhc%2Fweb%2Fwiklou.git do not parse malformed sections for section editing (fix bug #186) --- diff --git a/includes/Article.php b/includes/Article.php index 09742e060f..cd3abe6aeb 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -265,14 +265,14 @@ class Article { # split it up by section $secs = preg_split( - '/(^=+.*?=+|^.*?<\/h[1-6].*?' . '>)/mi', + '/(^=+.+?=+|^.*?<\/h[1-6].*?' . '>)(?!\S)/mi', $striptext, -1, PREG_SPLIT_DELIM_CAPTURE); if($section==0) { $rv=$secs[0]; } else { $headline=$secs[$section*2-1]; - preg_match( '/^(=+).*?=+|^.*?<\/h[1-6].*?' . '>/mi',$headline,$matches); + preg_match( '/^(=+).+?=+|^.*?<\/h[1-6].*?' . '>(?!\S)/mi',$headline,$matches); $hlevel=$matches[1]; # translate wiki heading into level @@ -287,7 +287,7 @@ class Article { while(!empty($secs[$count*2-1]) && !$break) { $subheadline=$secs[$count*2-1]; - preg_match( '/^(=+).*?=+|^.*?<\/h[1-6].*?' . '>/mi',$subheadline,$matches); + preg_match( '/^(=+).+?=+|^.*?<\/h[1-6].*?' . '>(?!\S)/mi',$subheadline,$matches); $subhlevel=$matches[1]; if(strpos($subhlevel,'=')!==false) { $subhlevel=strlen($subhlevel); @@ -864,7 +864,7 @@ class Article { # split it up # Unfortunately we can't simply do a preg_replace because that might # replace the wrong section, so we have to use the section counter instead - $secs=preg_split('/(^=+.*?=+|^.*?<\/h[1-6].*?' . '>)/mi', + $secs=preg_split('/(^=+.+?=+|^.*?<\/h[1-6].*?' . '>)(?!\S)/mi', $oldtext,-1,PREG_SPLIT_DELIM_CAPTURE); $secs[$section*2]=$text."\n\n"; // replace with edited @@ -876,7 +876,7 @@ class Article { # be erased, as the mother section has been replaced with # the text of all subsections. $headline=$secs[$section*2-1]; - preg_match( '/^(=+).*?=+|^.*?<\/h[1-6].*?' . '>/mi',$headline,$matches); + preg_match( '/^(=+).+?=+|^.*?<\/h[1-6].*?' . '>(?!\S)/mi',$headline,$matches); $hlevel=$matches[1]; # determine headline level for wikimarkup headings @@ -891,7 +891,7 @@ class Article { $subheadline=$secs[$count*2-1]; preg_match( - '/^(=+).*?=+|^.*?<\/h[1-6].*?' . '>/mi',$subheadline,$matches); + '/^(=+).+?=+|^.*?<\/h[1-6].*?' . '>(?!\S)/mi',$subheadline,$matches); $subhlevel=$matches[1]; if(strpos($subhlevel,'=')!==false) { $subhlevel=strlen($subhlevel);