Update Website.php to support arrays in form variables, a=chris

Chris Pollett [2022-08-03 00:Aug:rd]
Update Website.php to support arrays in form variables, a=chris
Filename
src/configs/default_crawl.ini
src/controllers/components/CrawlComponent.php
src/library/LocaleFunctions.php
src/library/WebSite.php
src/models/CrawlModel.php
diff --git a/src/configs/default_crawl.ini b/src/configs/default_crawl.ini
index ec282b3ba..9ee61be1b 100644
--- a/src/configs/default_crawl.ini
+++ b/src/configs/default_crawl.ini
@@ -62,6 +62,7 @@ extensions[] = 'cfml';
 extensions[] = 'do';
 extensions[] = 'htm';
 extensions[] = 'html';
+extensions[] = 'ico';
 extensions[] = 'jsp';
 extensions[] = 'php';
 extensions[] = 'pl';
diff --git a/src/controllers/components/CrawlComponent.php b/src/controllers/components/CrawlComponent.php
index 50f0ae28f..157a03006 100644
--- a/src/controllers/components/CrawlComponent.php
+++ b/src/controllers/components/CrawlComponent.php
@@ -1719,7 +1719,7 @@ class CrawlComponent extends Component implements CrawlConstants
         $data['INDEXED_FILE_TYPES'] = [];
         $filetypes = [];
         foreach (PageProcessor::$indexed_file_types as $filetype) {
-            $ison =false;
+            $ison = false;
             if (isset($_REQUEST["filetype"]) && !$loaded) {
                 if (isset($_REQUEST["filetype"][$filetype])) {
                     $filetypes[] = $filetype;
diff --git a/src/library/LocaleFunctions.php b/src/library/LocaleFunctions.php
index cf60ff45b..a2fc3d4b4 100755
--- a/src/library/LocaleFunctions.php
+++ b/src/library/LocaleFunctions.php
@@ -148,6 +148,9 @@ function guessLocaleFromString($phrase_string, $locale_tag = null)
         foreach (localesWithStopwordsList() as $lang) {
             $tokenizer = PhraseParser::getTokenizer($lang);
             if ($tokenizer) {
+                /* keep next line as stopWordRemover uses preg_replace
+                   while will return null if $guess_string is not UTF-8
+                 */
                 $guess_string = mb_convert_encoding($guess_string, "UTF-8");
                 $compressed_string =
                     $tokenizer->stopwordsRemover($guess_string);
diff --git a/src/library/WebSite.php b/src/library/WebSite.php
index 2272c5cf3..2f63540b5 100644
--- a/src/library/WebSite.php
+++ b/src/library/WebSite.php
@@ -1523,7 +1523,21 @@ class WebSite
                     continue;
                 }
                 if (empty($file_name)) {
-                    $_POST[$name] = rtrim($content, "\x0D\x0A");
+                    //we support up to 3D arrays in form variables
+                    if (preg_match("/^(\w+)\[(\w+)\]\[(\w+)\]\[(\w+)\]$/",
+                        $name, $matches)) {
+                        $_POST[$matches[1]][$matches[2]][$matches[3]][
+                            $matches[4]] = $content;
+                    } else if (preg_match("/^(\w+)\[(\w+)\]\[(\w+)\]$/", $name,
+                        $matches)) {
+                        $_POST[$matches[1]][$matches[2]][$matches[3]] =
+                            $content;
+                    } else if (preg_match("/^(\w+)\[(\w+)\]$/", $name,
+                        $matches)) {
+                        $_POST[$matches[1]][$matches[2]] = $content;
+                    } else {
+                        $_POST[$name] = rtrim($content, "\x0D\x0A");
+                    }
                     continue;
                 }
                 $file_array = ['name' => $file_name, 'tmp_name' => $file_name,
diff --git a/src/models/CrawlModel.php b/src/models/CrawlModel.php
index 41724bed1..fdb035095 100755
--- a/src/models/CrawlModel.php
+++ b/src/models/CrawlModel.php
@@ -541,7 +541,7 @@ EOT;
         }
         $out = implode("\n", $n);
         $out .= "\n";
-        file_put_contents(C\WORK_DIRECTORY."/crawl.ini", $out);
+        file_put_contents(C\WORK_DIRECTORY . "/crawl.ini", $out);
     }
     /**
      * Returns the crawl parameters that were used during a given crawl
ViewGit