LibreY

- privacy respecting meta search engine
git clone git://git.acid.vegas/LibreY.git
Log | Files | Refs | Archive | README | LICENSE

commit 9296cb46005d93665c883431cfbe3ef28fe04c50
parent 903ec514834075aa6b8af7c078b45de7e5854e43
Author: Ahwx <ahwx@ahwx.org>
Date: Sat, 19 Aug 2023 11:49:35 +0200

fix: passing quotation marks to google searches (merge pull request #13 from davidovski/quote_searches) Fix passing quotation marks to google searches

Diffstat:
Mengines/google/text.php | 3++-
Msearch.php | 4++--

2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/engines/google/text.php b/engines/google/text.php
@@ -4,7 +4,7 @@
         global $config;
 
         $mh = curl_multi_init();
-        $query_encoded = urlencode($query);
+        $query_encoded = str_replace("%22", "\"", urlencode($query));
         $results = array();
 
         $domain = $config->google_domain;
@@ -13,6 +13,7 @@
         $number_of_results = isset($_COOKIE["google_number_of_results"]) ? trim(htmlspecialchars($_COOKIE["google_number_of_results"])) : $config->google_number_of_results;
 
         $url = "https://www.google.$domain/search?q=$query_encoded&nfpr=1&start=$page";
+        error_log($url);
 
         if (3 > strlen($site_language) && 0 < strlen($site_language))
             $url .= "&hl=$site_language";
diff --git a/search.php b/search.php
@@ -7,7 +7,7 @@
 
 <title>
 <?php
-  $query = htmlspecialchars(trim($_REQUEST["q"]));
+  $query = trim($_REQUEST["q"]);
   echo $query;
 ?> - LibreY</title>
 </head>
@@ -24,7 +24,7 @@
                         die();
                     }
 
-                    echo "value=\"$query\"";
+                    echo "value=\"" . htmlspecialchars($query) . "\"";
                 ?>
             >
             <br>