[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdelibs/khtml [POSSIBLY UNSAFE]
From:       George Staikos <staikos () kde ! org>
Date:       2004-10-29 22:07:03
Message-ID: 20041029220703.D5A7D16BCB () office ! kde ! org
[Download RAW message or body]

CVS commit by staikos: 

properly pick up files when $PWD != KGlobalSettings::documentPath(), and
actually make file input elements complete from that location in all cases.
The code is a bit more complex than necessary, but at least it's easy to
change now if more people agree with me that launching konqueror from
$foodir should complete in KURLRequester under $foodir and not under
KGlobalSettings::documentPath()


  M +22 -5     html/html_formimpl.cpp   1.395 [POSSIBLY UNSAFE: qDebug]
  M +3 -1      rendering/render_form.cpp   1.280


--- kdelibs/khtml/rendering/render_form.cpp  #1.279:1.280
@@ -36,4 +36,5 @@
 #include <kreplacedialog.h>
 #include <kspell.h>
+#include <kurlcompletion.h>
 #include <kwin.h>
 
@@ -721,4 +722,5 @@ RenderFileButton::RenderFileButton(HTMLI
 
     w->setMode(KFile::File | KFile::ExistingOnly);
+    w->completionObject()->setDir(KGlobalSettings::documentPath());
 
     connect(w->lineEdit(), SIGNAL(returnPressed()), this, \
SLOT(slotReturnPressed()));

--- kdelibs/khtml/html/html_formimpl.cpp  #1.394:1.395
@@ -293,5 +293,13 @@ QByteArray HTMLFormElementImpl::formData
                         current->renderer())
                     {
-                        const KURL path ( \
static_cast<HTMLInputElementImpl*>(current)->value().string()); +                     \
KURL path; +                        QString val = \
static_cast<HTMLInputElementImpl*>(current)->value().string(); +                      \
if (!val.isEmpty() && +                            QDir::isRelativePath(val) && 
+                            QFile::exists(KGlobalSettings::documentPath() + val)) {
+                            path.setPath(KGlobalSettings::documentPath() + val);
+                        } else {
+                            path = KURL::fromPathOrURL(val);
+                        }
 
                         hstr += fixUpfromUnicode(codec, "; filename=\"" + \
path.fileName() + "\""); @@ -1397,5 +1405,5 @@ bool \
HTMLInputElementImpl::encoding(cons  break;
 
-        case FILE:
+        case FILE: // hmm, we have the type FILE also.  bad choice here...
         {
             // don't submit if display: none or display: hidden
@@ -1404,5 +1412,14 @@ bool HTMLInputElementImpl::encoding(cons
 
             QString local;
-            const KURL fileurl(value().string());
+            KURL fileurl;
+            QString val = value().string();
+            if (!val.isEmpty() &&
+                QDir::isRelativePath(val) &&
+                QFile::exists(KGlobalSettings::documentPath() + val)) {
+                fileurl.setPath(KGlobalSettings::documentPath() + val);
+            } else {
+                fileurl = KURL::fromPathOrURL(val);
+            }
+qDebug("URL: %s", fileurl.url().latin1());
             KIO::UDSEntry filestat;
 
@@ -1414,5 +1431,5 @@ bool HTMLInputElementImpl::encoding(cons
                     const KFileItem fileitem(filestat, fileurl, true, false);
                     if ( fileitem.isFile() &&
-                         KIO::NetAccess::download(KURL(value().string()), local, \
toplevel) ) { +                         KIO::NetAccess::download(fileurl, local, \
toplevel) ) {  QFile file(local);
                         filearray.resize(file.size()+1);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic