Bug 128125 - Album title from digikam are not converted into html entities
Summary: Album title from digikam are not converted into html entities
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-Generic-HTMLGallery (show other bugs)
Version: unspecified
Platform: Mandriva RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-27 11:58 UTC by Maxime Delorme
Modified: 2017-06-30 05:47 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 5.7.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Maxime Delorme 2006-05-27 11:58:03 UTC
Version:            (using KDE KDE 3.5.0)
Installed from:    Mandriva RPMs

When using from Digikam the cd_archiving plugin, the result is an html album browsable from the CD burned.
But when folder name contain double quote, the link from the index page is broken because double quote are not converted to their html entities equivalent.
So picture is not visible and link doesn't work
Comment 1 Maxime Delorme 2006-05-27 12:01:10 UTC
I'm using kipi plugins version : 0.1.0-0.rc1.2.1.20060mdk
Comment 2 Angelo Naselli 2006-05-27 12:25:24 UTC
Alle 11:58, sabato 27 maggio 2006, Maxime Delorme ha scritto:
> double quote

Can you check if html export is affected as well please?

Thanks,
	Angelo
Comment 3 Maxime Delorme 2006-05-27 12:38:10 UTC
Yes it is as well
Comment 4 Angelo Naselli 2006-06-02 21:32:40 UTC
SVN commit 547624 by anaselli:

Added webifyFileName (from html gallery)
and moved png file from old imagesgallery plugin
BUG: 101656
BUG: 128125

 M  +2 -0      Makefile.am  
 M  +39 -20    cdarchiving.cpp  
 M  +2 -0      cdarchiving.h  
 AM            gohome.png  
 AM            up.png  
 AM            valid-html401.png  


--- trunk/extragear/libs/kipi-plugins/cdarchiving/Makefile.am #547623:547624
@@ -25,3 +25,5 @@
 kipiimagebrokenpicdir = $(kde_datadir)/kipi/data
 kipiimagebrokenpic_DATA = image_broken.png
 
+kipiHTML401picdir = $(kde_datadir)/kipi
+kipiHTML401pic_DATA = valid-html401.png gohome.png up.png
--- trunk/extragear/libs/kipi-plugins/cdarchiving/cdarchiving.cpp #547623:547624
@@ -38,6 +38,7 @@
 #include <qimage.h>
 #include <qtextcodec.h>
 #include <qtimer.h>
+#include <qregexp.h>
 
 // Include files for KDE
 
@@ -530,7 +531,7 @@
         KIPI::ImageCollection album = *it;
         kdDebug( 51000 ) << "HTML Interface for Album: " << album.name() << endl;
 
-        m_AlbumTitle      = album.name();
+        m_AlbumTitle      = webifyFileName(album.name());
         m_AlbumComments   = m_interface->hasFeature(KIPI::AlbumsHaveComments) ?
                             album.comment() : QString();
         m_AlbumCollection = m_interface->hasFeature(KIPI::AlbumsHaveCategory) ?
@@ -793,15 +794,15 @@
         {
             stream << "<tr>" << endl;
         }
-        
+
         QString   imgName = (*urlIt).fileName();
         QString   imgPath = (*urlIt).path();
         QFileInfo imgInfo(imgPath);
         QImage    imgProp = QImage(imgPath);
 
-        stream << "<td align='center'>\n<a href=\"pages/"  << imgName << ".htm\">";
+        stream << "<td align='center'>\n<a href=\"pages/"  << webifyFileName(imgName) << ".htm\">";
         kdDebug(51000) << "Creating thumbnail for " << imgName << endl;
-            
+
         d = new KIPICDArchivingPlugin::EventData;
         d->action = KIPICDArchivingPlugin::ResizeImages;
         d->starting = true;
@@ -809,13 +810,13 @@
         d->fileName = imgName;
         QApplication::sendEvent(m_parent, new QCustomEvent(QEvent::User, d));
         usleep(1000);
-            
+
         int valRet = createThumb(imgName, (*urlIt).directory(),
                                  imgGalleryDir, imageFormat);
-            
+
         if ( valRet != -1 )
         {
-            QString thumbPath("thumbs/" + imgName + extension(imageFormat));
+            QString thumbPath("thumbs/" + webifyFileName(imgName) + extension(imageFormat));
             stream << "<img class=\"photo\" src=\"" << thumbPath
                    << "\" width=\"" << m_imgWidth
                    << "\" "
@@ -1054,26 +1055,26 @@
     const QDir pagesDir(imgGalleryDir + QString::fromLatin1("/pages/"));
     const QDir thumbsDir(imgGalleryDir + QString::fromLatin1("/thumbs/"));
     const QString imgName(imgURL.fileName());
-    
+
     // Html pages filenames
 
     const QString pageFilename = pagesDir.path() +
                                  QString::fromLatin1("/") +
-                                 imgName +
+                                 webifyFileName(imgName )+
                                  QString::fromLatin1(".htm");
-    const QString nextPageFilename =  nextImgURL.fileName() +
+    const QString nextPageFilename =  webifyFileName(nextImgURL.fileName()) +
                                       QString::fromLatin1(".htm");
-    const QString prevPageFilename =  prevImgURL.fileName() +
+    const QString prevPageFilename =  webifyFileName(prevImgURL.fileName()) +
                                       QString::fromLatin1(".htm");
 
     // Thumbs filenames
 
     const QString prevThumb = QString::fromLatin1("../thumbs/") +
-                              prevImgURL.fileName() +
+                              webifyFileName(prevImgURL.fileName()) +
                               extension(m_imageFormat);
 
     const QString nextThumb = QString::fromLatin1("../thumbs/") +
-                              nextImgURL.fileName() +
+                              webifyFileName(nextImgURL.fileName()) +
                               extension(m_imageFormat);
 
     QFile file( pageFilename );
@@ -1240,7 +1241,7 @@
 
     // Create the thumbnails for the HTML interface.
 
-    const QString ImageNameFormat = imgName + extension(imageFormat);
+    const QString ImageNameFormat = webifyFileName(imgName) + extension(imageFormat);
     const QString thumbDir = imgGalleryDir + QString::fromLatin1("/thumbs/");
     int extent = m_thumbnailsSize;
 
@@ -1580,10 +1581,9 @@
    QDir dir(dirname);
    dir.setFilter ( QDir::Dirs | QDir::Files | QDir::NoSymLinks );
 
-   Temp = "<directory name=\""
-          + EscapeSgmlText(QTextCodec::codecForLocale(), dir.dirName(), true, true)
-          + "\" >\n";
-
+      Temp = "<directory name=\""
+            + EscapeSgmlText(QTextCodec::codecForLocale(), dir.dirName(), true, true)
+            + "\" >\n";
    *stream << Temp;
    
    kdDebug( 51000 ) << "Directory: " << dir.dirName().latin1 () << endl;
@@ -1650,12 +1650,17 @@
    kdDebug( 51000 ) << "Adding Collection: " << collection.name() << endl;
 
    QString Temp;
+   QString collection_name;
+   if (m_useHTMLInterface)
+    collection_name = webifyFileName(collection.name());
+   else
+    collection_name = collection.name();
 
    Temp = "<directory name=\""
-          + EscapeSgmlText(QTextCodec::codecForLocale(), collection.name(), true, true)
+          + EscapeSgmlText(QTextCodec::codecForLocale(), collection_name, true, true)
           + "\" >\n";
    *stream << Temp;
-   
+
    KURL::List images = collection.images();
 
    for (KURL::List::iterator it = images.begin();
@@ -1853,6 +1858,20 @@
     return strReturn;
 }
 
+
+/**
+ * Produce a web-friendly file name 
+ */
+
+QString CDArchiving::webifyFileName(QString fileName) {
+  fileName=fileName.lower();
+  
+  // Remove potentially troublesome chars
+  fileName=fileName.replace(QRegExp("[^-0-9a-zA-Z]+"), "_");
+
+  return fileName;
+}
+
 }  // NameSpace KIPICDArchivingPlugin
 
 #include "cdarchiving.moc"
--- trunk/extragear/libs/kipi-plugins/cdarchiving/cdarchiving.h #547623:547624
@@ -201,6 +201,8 @@
 
   void writeSettings(void);
   void readSettings(void);
+
+  QString webifyFileName(QString fileName);
 };
 
 }  // NameSpace KIPICDArchivingPlugin
** trunk/extragear/libs/kipi-plugins/cdarchiving/gohome.png #property svn:mime-type
   + application/octet-stream
** trunk/extragear/libs/kipi-plugins/cdarchiving/up.png #property svn:mime-type
   + application/octet-stream
** trunk/extragear/libs/kipi-plugins/cdarchiving/valid-html401.png #property svn:mime-type
   + application/octet-stream
Comment 5 caulier.gilles 2017-06-30 05:47:12 UTC
With new HTML Gallery tool from digiKam core, this problem is not reproducible.

Gilles Caulier