]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #552 from shaarli/readme-doc-plugins
authorArthur <arthur@hoa.ro>
Thu, 5 May 2016 12:41:20 +0000 (14:41 +0200)
committerArthur <arthur@hoa.ro>
Thu, 5 May 2016 12:41:20 +0000 (14:41 +0200)
add link to plugins doc

application/HttpUtils.php
application/TimeZone.php
application/Url.php
index.php
tests/TimeZoneTest.php
tests/Url/UrlTest.php

index 0e1ce8798878e3a8043d581da18e44427914bec8..c84ba6f05746d404b195607715556a67ccce8eba 100644 (file)
@@ -27,7 +27,7 @@
 function get_http_response($url, $timeout = 30, $maxBytes = 4194304)
 {
     $urlObj = new Url($url);
-    $cleanUrl = $urlObj->indToAscii();
+    $cleanUrl = $urlObj->idnToAscii();
 
     if (! filter_var($cleanUrl, FILTER_VALIDATE_URL) || ! $urlObj->isHttp()) {
         return array(array(0 => 'Invalid HTTP Url'), false);
@@ -70,7 +70,7 @@ function get_http_response($url, $timeout = 30, $maxBytes = 4194304)
  * Retrieve HTTP headers, following n redirections (temporary and permanent ones).
  *
  * @param string $url              initial URL to reach.
- * @param int    $redirectionLimit max redirection follow..
+ * @param int    $redirectionLimit max redirection follow.
  *
  * @return array HTTP headers, or false if it failed.
  */
index e363d90a789207b821493a98a65270ba63b1ae97..26f2232d45c1a5961d45380acf52de0beafd5b70 100644 (file)
@@ -101,10 +101,6 @@ function generateTimeZoneForm($preselectedTimezone='')
  */
 function isTimeZoneValid($continent, $city)
 {
-    if ($continent == 'UTC' && $city == 'UTC') {
-        return true;
-    }
-
     return in_array(
         $continent.'/'.$city,
         timezone_identifiers_list()
index 61a30a7800972d8d8c22fdad98a4023e1c561b23..77447c8df96635c17f55a90cb463a1313c35170a 100644 (file)
@@ -240,7 +240,7 @@ class Url
      *
      * @return string converted cleaned up URL.
      */
-    public function indToAscii()
+    public function idnToAscii()
     {
         $out = $this->cleanup();
         if (! function_exists('idn_to_ascii') || ! isset($this->parts['host'])) {
index e9b0bf4058e52f9843a9ecfd3408211abe3724b3..47bae6e87a943a1b26d5af2d1558053e2909f2fb 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1277,11 +1277,15 @@ function renderPage()
     {
         if (!empty($_POST['title']) )
         {
-            if (!tokenOk($_POST['token'])) die('Wrong token.'); // Go away!
+            if (!tokenOk($_POST['token'])) {
+                die('Wrong token.'); // Go away!
+            }
             $tz = 'UTC';
-            if (!empty($_POST['continent']) && !empty($_POST['city']))
-                if (isTimeZoneValid($_POST['continent'],$_POST['city']))
-                    $tz = $_POST['continent'].'/'.$_POST['city'];
+            if (!empty($_POST['continent']) && !empty($_POST['city'])
+                && isTimeZoneValid($_POST['continent'], $_POST['city'])
+            ) {
+                $tz = $_POST['continent'] . '/' . $_POST['city'];
+            }
             $GLOBALS['timezone'] = $tz;
             $GLOBALS['title']=$_POST['title'];
             $GLOBALS['titleLink']=$_POST['titleLink'];
@@ -2108,10 +2112,10 @@ function install()
     if (!empty($_POST['setlogin']) && !empty($_POST['setpassword']))
     {
         $tz = 'UTC';
-        if (!empty($_POST['continent']) && !empty($_POST['city'])) {
-            if (isTimeZoneValid($_POST['continent'], $_POST['city'])) {
-                $tz = $_POST['continent'].'/'.$_POST['city'];
-            }
+        if (!empty($_POST['continent']) && !empty($_POST['city'])
+            && isTimeZoneValid($_POST['continent'], $_POST['city'])
+        ) {
+            $tz = $_POST['continent'].'/'.$_POST['city'];
         }
         $GLOBALS['timezone'] = $tz;
         // Everything is ok, let's create config file.
index b219030a3a4da19f3c73b53d9a845723b4fb1352..2976d11612765dde427242073320c4d7f32bdb97 100644 (file)
@@ -67,7 +67,6 @@ class TimeZoneTest extends PHPUnit_Framework_TestCase
     {
         $this->assertTrue(isTimeZoneValid('America', 'Argentina/Ushuaia'));
         $this->assertTrue(isTimeZoneValid('Europe', 'Oslo'));
-        $this->assertTrue(isTimeZoneValid('UTC', 'UTC'));
     }
 
     /**
@@ -78,5 +77,6 @@ class TimeZoneTest extends PHPUnit_Framework_TestCase
         $this->assertFalse(isTimeZoneValid('CEST', 'CEST'));
         $this->assertFalse(isTimeZoneValid('Europe', 'Atlantis'));
         $this->assertFalse(isTimeZoneValid('Middle_Earth', 'Moria'));
+        $this->assertFalse(isTimeZoneValid('UTC', 'UTC'));
     }
 }
index 5fdc86177bdf9677317719b6f8f516fa5e89f351..ce82265e305bfceec3b69e232002a411f5ea0d67 100644 (file)
@@ -190,10 +190,10 @@ class UrlTest extends PHPUnit_Framework_TestCase
         $ind = 'http://www.académie-française.fr/';
         $expected = 'http://www.xn--acadmie-franaise-npb1a.fr/';
         $url = new Url($ind);
-        $this->assertEquals($expected, $url->indToAscii());
+        $this->assertEquals($expected, $url->idnToAscii());
 
         $notInd = 'http://www.academie-francaise.fr/';
         $url = new Url($notInd);
-        $this->assertEquals($notInd, $url->indToAscii());
+        $this->assertEquals($notInd, $url->idnToAscii());
     }
 }