fix for infinite loop when help files have trailing empty lines.
authorstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 15 Oct 2002 23:20:51 +0000 (23:20 +0000)
committerstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 15 Oct 2002 23:20:51 +0000 (23:20 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@3873 7612ce4b-ef26-0410-bec9-ea0150e637f0

src/help.php

index 99671fb..2da48ed 100644 (file)
@@ -41,7 +41,7 @@ $helpdir[8] = 'FAQ.hlp';
  */
 
 function get_info($doc, $pos) {
-
+    $ary = array(0,0,0);
     for ($n=$pos; $n < count($doc); $n++) {
         if (trim(strtolower($doc[$n])) == '<chapter>'
             || trim(strtolower($doc[$n])) == '<section>') {
@@ -77,12 +77,17 @@ function get_info($doc, $pos) {
                 $ary[2] = $ary[0];
             }
            return( $ary );
-        }
+        } else if (!trim(strtolower($doc[$n]))) {
+            $ary[0] = '';
+            $ary[1] = '';
+            $ary[2] = '';
+            $ary[3] = $n;
+       }
     }
-    
     $ary[0] = _("ERROR: Help files are not in the right format!");
     $ary[1] = $ary[0];
-
+    $ary[2] = $ary[0];
+    $ary[3] = $n;
     return( $ary );
 }
 
@@ -220,7 +225,7 @@ if ($help_exists == true) {
             $help_info = get_info($doc, $n);
             echo "<b>$chapter.$section - $help_info[0]</b>" .
                 html_tag( 'ul', $help_info[1] );
-            $n = $help_info[3];
+           $n = $help_info[3];
         }
 
         echo '<br><center><a href="#pagetop">' . _("Top") . '</a></center>';