Bug 123953 - Fail to open files in dirs with a %2f (aka a slash)
Summary: Fail to open files in dirs with a %2f (aka a slash)
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: General (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Cyrille Berger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-20 01:06 UTC by Thomas Zander
Modified: 2006-03-28 17:54 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Zander 2006-03-20 01:06:11 UTC
Version:           unknown (using KDE 3.5.1, compiled sources)
Compiler:          Target: x86_64-linux-gnu
OS:                Linux (x86_64) release 2.6.13.2

To reproduce:

1) in konqueror create a dir with the name "foo/bar"  (yes, including the slash)
2) copy an image into the new dir
3) still in konq, open image in krita (using open with since krita seems to not be listed most of the times).

You get a dialog that says:
Could not open /home/zander/foo%252fbar/image.png.
Reason: Cannot create storage

Note that I have no idea where the %252 comes from; an ls states that the dir is actally 'foo%2fbar'. Where did that 52 come from??
Comment 1 Thiago Macieira 2006-03-24 19:09:00 UTC
/ = %2f
but % = %25
so %2f = %252f
Comment 2 David Faure 2006-03-27 16:30:32 UTC
> / = %2f
> but % = %25
> so %2f = %252f


I guess the bug here is a path/url confusion in krita, since it shouldn't
care that the directory is actually called foo%2fbar on disk.
But by extracting a path wrongly (e.g. removing ("file:/") from a URL), you
get a wrongly encoded path (same problem would happen with '#' in the path).
Comment 3 Halla Rempt 2006-03-27 16:33:04 UTC
I'll set the product to Krita and assign the bug to our fearless png import filter maintainer. Cyrille: could you also check jpeg and tiff?
Comment 4 Cyrille Berger 2006-03-28 16:24:56 UTC
imagemagick has also the problem ;)
Comment 5 Cyrille Berger 2006-03-28 17:54:54 UTC
SVN commit 523602 by berger:

fix opening of weird directory (or filename) with a "/" (thanks to david)
BUG:123953


 M  +3 -1      jpeg/kis_jpeg_converter.cc  
 M  +2 -1      jpeg/kis_jpeg_export.cc  
 M  +2 -1      jpeg/kis_jpeg_import.cc  
 M  +3 -1      magick/kis_image_magick_converter.cc  
 M  +2 -1      magick/magickexport.cpp  
 M  +2 -1      magick/magickimport.cpp  
 M  +5 -1      png/kis_png_converter.cc  
 M  +2 -1      png/kis_png_export.cc  
 M  +2 -1      png/kis_png_import.cc  
 M  +3 -1      tiff/kis_tiff_converter.cc  
 M  +2 -1      tiff/kis_tiff_export.cc  
 M  +2 -1      tiff/kis_tiff_import.cc  


--- branches/koffice/1.5/koffice/filters/krita/jpeg/kis_jpeg_converter.cc #523601:523602
@@ -331,7 +331,9 @@
     QString tmpFile;
 
     if (KIO::NetAccess::download(uri, tmpFile, qApp -> mainWidget())) {
-        result = decode(tmpFile);
+        KURL uriTF;
+        uriTF.setPath( tmpFile );
+        result = decode(uriTF);
         KIO::NetAccess::removeTempFile(tmpFile);
     }
 
--- branches/koffice/1.5/koffice/filters/krita/jpeg/kis_jpeg_export.cc #523601:523602
@@ -118,7 +118,8 @@
     
     if (filename.isEmpty()) return KoFilter::FileNotFound;
 
-    KURL url(filename);
+    KURL url;
+    url.setPath(filename);
 
     KisImageSP img = output->currentImage();
     Q_CHECK_PTR(img);
--- branches/koffice/1.5/koffice/filters/krita/jpeg/kis_jpeg_import.cc #523601:523602
@@ -61,7 +61,8 @@
 
     if (!filename.isEmpty()) {
     
-        KURL url(filename);
+        KURL url;
+        url.setPath(filename);
 
         if (url.isEmpty())
             return KoFilter::FileNotFound;
--- branches/koffice/1.5/koffice/filters/krita/magick/kis_image_magick_converter.cc #523601:523602
@@ -615,7 +615,9 @@
         QString tmpFile;
 
         if (KIO::NetAccess::download(uri, tmpFile, qApp -> mainWidget())) {
-            result = decode(tmpFile, false);
+            KURL uriTF;
+            uriTF.setPath( tmpFile );
+            result = decode(uriTF, false);
             KIO::NetAccess::removeTempFile(tmpFile);
         }
 
--- branches/koffice/1.5/koffice/filters/krita/magick/magickexport.cpp #523601:523602
@@ -56,7 +56,8 @@
     
     if (filename.isEmpty()) return KoFilter::FileNotFound;
 
-    KURL url(filename);
+    KURL url;
+    url.setPath(filename);
 
     KisImageSP img = output->currentImage();
 
--- branches/koffice/1.5/koffice/filters/krita/magick/magickimport.cpp #523601:523602
@@ -61,7 +61,8 @@
 
     if (!filename.isEmpty()) {
     
-        KURL url(filename);
+        KURL url;
+        url.setPath(filename);
 
         if (url.isEmpty())
             return KoFilter::FileNotFound;
--- branches/koffice/1.5/koffice/filters/krita/png/kis_png_converter.cc #523601:523602
@@ -122,6 +122,7 @@
 {
     kdDebug(41008) << "Start decoding PNG File" << endl;
     // open the file
+    kdDebug(41008) << QFile::encodeName(uri.path()) << " " << uri.path() << " " << uri << endl;
     FILE *fp = fopen(QFile::encodeName(uri.path()), "rb");
     if (!fp)
     {
@@ -411,6 +412,7 @@
 
 KisImageBuilder_Result KisPNGConverter::buildImage(const KURL& uri)
 {
+    kdDebug(41008) << QFile::encodeName(uri.path()) << " " << uri.path() << " " << uri << endl;
     if (uri.isEmpty())
         return KisImageBuilder_RESULT_NO_URI;
 
@@ -423,7 +425,9 @@
     QString tmpFile;
 
     if (KIO::NetAccess::download(uri, tmpFile, qApp -> mainWidget())) {
-        result = decode(tmpFile);
+        KURL uriTF;
+        uriTF.setPath( tmpFile );
+        result = decode(uriTF);
         KIO::NetAccess::removeTempFile(tmpFile);
     }
 
--- branches/koffice/1.5/koffice/filters/krita/png/kis_png_export.cc #523601:523602
@@ -80,7 +80,8 @@
     
     if (filename.isEmpty()) return KoFilter::FileNotFound;
 
-    KURL url(filename);
+    KURL url;
+    url.setPath(filename);
 
     KisImageSP img = output->currentImage();
 
--- branches/koffice/1.5/koffice/filters/krita/png/kis_png_import.cc #523601:523602
@@ -61,7 +61,8 @@
 
     if (!filename.isEmpty()) {
     
-        KURL url(filename);
+        KURL url;
+        url.setPath(filename);
 
         if (url.isEmpty())
             return KoFilter::FileNotFound;
--- branches/koffice/1.5/koffice/filters/krita/tiff/kis_tiff_converter.cc #523601:523602
@@ -595,7 +595,9 @@
     QString tmpFile;
 
     if (KIO::NetAccess::download(uri, tmpFile, qApp -> mainWidget())) {
-        result = decode(tmpFile);
+        KURL uriTF;
+        uriTF.setPath( tmpFile );
+        result = decode(uriTF);
         KIO::NetAccess::removeTempFile(tmpFile);
     }
 
--- branches/koffice/1.5/koffice/filters/krita/tiff/kis_tiff_export.cc #523601:523602
@@ -76,7 +76,8 @@
     
     if (filename.isEmpty()) return KoFilter::FileNotFound;
 
-    KURL url(filename);
+    KURL url;
+    url.setPath(filename);
 
     KisImageSP img;
     
--- branches/koffice/1.5/koffice/filters/krita/tiff/kis_tiff_import.cc #523601:523602
@@ -61,7 +61,8 @@
 
     if (!filename.isEmpty()) {
     
-        KURL url(filename);
+        KURL url;
+        url.setPath(filename);
 
         if (url.isEmpty())
             return KoFilter::FileNotFound;