MDL-41672 Fix html2text processing of multiple occurrences of the same URL
authorAlain Corbière <alain.corbiere@univ-lemans.fr>
Wed, 9 Oct 2013 13:40:38 +0000 (15:40 +0200)
committerDavid Mudrák <david@moodle.com>
Wed, 9 Oct 2013 13:40:38 +0000 (15:40 +0200)
lib/html2text.php

index f01ce8f..7b9eb29 100644 (file)
@@ -580,9 +580,14 @@ class html2text
         }
 
         if (($index = array_search($url, $this->_link_list)) === false) {
+            // Add the link to the list.
             $this->_link_list[] = $url;
             $index = count($this->_link_list);
         }
+        else {
+            // Use the index of the existing link in the list (we enumerate from 1, not from 0).
+            $index++;
+        }
 
         return $display . ' [' . ($index) . ']';
     }