mirror of
https://github.com/Universal-Omega/DynamicPageList3
synced 2024-11-27 17:40:13 +00:00
Fix infinite loop if section header has ( (#283)
This commit is contained in:
parent
1aef9d71af
commit
cf3b9cc6a0
|
@ -480,9 +480,7 @@ class LST {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( preg_match( "/$pat/im", $text, $m, PREG_OFFSET_CAPTURE ) ) {
|
if ( preg_match( "/$pat/im", $text, $m, PREG_OFFSET_CAPTURE ) ) {
|
||||||
$mata = [];
|
$begin_off = end($m)[1];
|
||||||
$no_parenthesis = preg_match_all( '/\(/', $pat, $mata );
|
|
||||||
$begin_off = $m[$no_parenthesis][1];
|
|
||||||
$head_len = strlen( $m[1][0] );
|
$head_len = strlen( $m[1][0] );
|
||||||
$headLine = trim( $m[0][0], "\n =\t" );
|
$headLine = trim( $m[0][0], "\n =\t" );
|
||||||
} elseif ( $nr == -2 ) {
|
} elseif ( $nr == -2 ) {
|
||||||
|
@ -559,6 +557,11 @@ class LST {
|
||||||
if ( $sec == '' ) {
|
if ( $sec == '' ) {
|
||||||
$continueSearch = false;
|
$continueSearch = false;
|
||||||
} else {
|
} else {
|
||||||
|
if ( $end_off == 0 ) {
|
||||||
|
// we have made no progress - something has gone wrong, but at least don't loop forever
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// this could lead to quadratic runtime...
|
||||||
$text = substr( $text, $end_off );
|
$text = substr( $text, $end_off );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue