issue #316 makes it necessary to urldecode F-Spots photo uri, fixes #317
authorAndreas Unterkircher <unki@netshadow.at>
Fri, 15 Jan 2010 18:26:15 +0000 (19:26 +0100)
committerAndreas Unterkircher <unki@netshadow.at>
Fri, 15 Jan 2010 18:46:55 +0000 (19:46 +0100)
Signed-off-by: Andreas Unterkircher <unki@netshadow.at>
phpfspot.class.php

index a69cdde..e220a7c 100644 (file)
@@ -559,6 +559,10 @@ class PHPFSPOT {
          if($this->dbver < 9) {
             $row['uri'] = "file://". $row['directory_path'] ."/". $row['name'];
          }
+         /* starting with dbversion >= 17 we need to rawurldecode() uri */
+         elseif($this->dbver >= 17) {
+            $row['uri'] = rawurldecode($row['uri']);
+         }
 
          /* if version-idx has not yet been set, get the latest photo version */
          if(!isset($version_idx) || !$this->is_valid_version($idx, $version_idx))
@@ -600,7 +604,7 @@ class PHPFSPOT {
                      version_id LIKE '". $version_idx ."'")) {
 
                   $row['name'] = $version['name'];
-                  $row['uri'] = $version['uri'];
+                  $row['uri'] = rawurldecode($version['uri']);
                }
             }
          }
@@ -3500,23 +3504,24 @@ class PHPFSPOT {
     */
    public function parse_uri($uri, $mode)
    {
-      if(($components = parse_url($uri)) !== false) {
+      if(($components = parse_url($uri)) === false)
+         return $uri;
 
-         switch($mode) {
-            case 'filename':
-               return basename($components['path']);
-               break;
-            case 'dirname':
-               return dirname($components['path']);
-               break;
-            case 'fullpath':
-               return $components['path'];
-               break;
-         }
+      switch($mode) {
+         case 'filename':
+            return basename($components['path']);
+            break;
+         case 'dirname':
+            return dirname($components['path']);
+            break;
+         case 'fullpath':
+            return $components['path'];
+            break;
+         default:
+            $this->throwError("unknown mode ". $mode);
+            break;
       }
 
-      return $uri;
-
    } // parse_uri()
 
    /**