Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Molkentin <danimo@owncloud.com>2013-08-05 21:45:16 +0400
committerDaniel Molkentin <danimo@owncloud.com>2013-08-05 21:45:24 +0400
commit26bd164168e7282fdf5da7aa2d7dd5620cbb01c9 (patch)
tree1331cc80b09699cd392d0f98c2e635cd22f34f68 /src
parent203b9c7f6b2b60aeb7725c1612683c7f0dcd15cf (diff)
Safer implementation for substitution of WebDav URL
- Use of RegEx is dangerous with folder names containing e.g. '(' or ')'. - Didn't work in my case at all.
Diffstat (limited to 'src')
-rw-r--r--src/mirall/accountsettings.cpp7
-rw-r--r--src/mirall/folder.cpp21
-rw-r--r--src/mirall/owncloudinfo.cpp1
-rw-r--r--src/mirall/owncloudinfo.h1
-rw-r--r--src/mirall/utility.cpp13
-rw-r--r--src/mirall/utility.h1
6 files changed, 22 insertions, 22 deletions
diff --git a/src/mirall/accountsettings.cpp b/src/mirall/accountsettings.cpp
index e66f43bea..788ebf39f 100644
--- a/src/mirall/accountsettings.cpp
+++ b/src/mirall/accountsettings.cpp
@@ -493,10 +493,9 @@ QString AccountSettings::shortenFilename( const QString& folder, const QString&
// rip off the whole ownCloud URL.
Folder *f = FolderMan::instance()->folder(folder);
if( f ) {
- QString regexp = QString("^owncloud[s]*://.*/remote.php/webdav/%1/").arg(f->secondPath());
- QRegExp re( regexp );
- re.setMinimal(true);
- shortFile.remove(re);
+ QString remotePathUrl = ownCloudInfo::instance()->webdavUrl() + QLatin1Char('/') + f->secondPath();
+ shortFile.remove(Utility::toCSyncScheme(remotePathUrl));
+
}
}
return shortFile;
diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp
index e6752a1e2..16fe8c1a1 100644
--- a/src/mirall/folder.cpp
+++ b/src/mirall/folder.cpp
@@ -43,19 +43,6 @@ void csyncLogCatcher(CSYNC *ctx,
Logger::instance()->csyncLog( QString::fromUtf8(buffer) );
}
-static QString replaceScheme(const QString &urlStr)
-{
-
- QUrl url( urlStr );
- if( url.scheme() == QLatin1String("http") ) {
- url.setScheme( QLatin1String("owncloud") );
- } else {
- // connect SSL!
- url.setScheme( QLatin1String("ownclouds") );
- }
- return url.toString();
-}
-
Folder::Folder(const QString &alias, const QString &path, const QString& secondPath, QObject *parent)
: QObject(parent)
, _path(path)
@@ -92,7 +79,7 @@ Folder::Folder(const QString &alias, const QString &path, const QString& secondP
bool Folder::init()
{
- QString url = replaceScheme(ownCloudInfo::instance()->webdavUrl() + secondPath());
+ QString url = Utility::toCSyncScheme(ownCloudInfo::instance()->webdavUrl() + secondPath());
QString localpath = path();
if( csync_create( &_csync_ctx, localpath.toUtf8().data(), url.toUtf8().data() ) < 0 ) {
@@ -596,10 +583,8 @@ void Folder::slotTransmissionProgress(const Progress::Info& progress)
if(newInfo.current_file.startsWith(QLatin1String("ownclouds://")) ||
newInfo.current_file.startsWith(QLatin1String("owncloud://")) ) {
// rip off the whole ownCloud URL.
- QString regexp = QString("^owncloud[s]*://.*/remote.php/webdav/%1/").arg(secondPath());
- QRegExp re( regexp );
- re.setMinimal(true);
- newInfo.current_file.remove(re);
+ QString remotePathUrl = ownCloudInfo::instance()->webdavUrl() + secondPath();
+ newInfo.current_file.remove(Utility::toCSyncScheme(remotePathUrl));
}
QString localPath = path();
if( newInfo.current_file.startsWith(localPath) ) {
diff --git a/src/mirall/owncloudinfo.cpp b/src/mirall/owncloudinfo.cpp
index 3318c89df..e31a7d609 100644
--- a/src/mirall/owncloudinfo.cpp
+++ b/src/mirall/owncloudinfo.cpp
@@ -608,6 +608,7 @@ QString ownCloudInfo::webdavUrl(const QString &connection)
url = cfgFile.ownCloudUrl( connection );
}
url.append( QLatin1String( WEBDAV_PATH ) );
+ if (!url.endsWith('/')) url.append('/');
return url;
}
diff --git a/src/mirall/owncloudinfo.h b/src/mirall/owncloudinfo.h
index fa395dd32..03b171e30 100644
--- a/src/mirall/owncloudinfo.h
+++ b/src/mirall/owncloudinfo.h
@@ -111,6 +111,7 @@ public:
/**
* returns the owncloud webdav url.
* It may be different from the one in the config if there was a HTTP redirection
+ * The returned URL is guaranteed to end in a forward slash ('/')
*/
QString webdavUrl(const QString& connection = QString());
diff --git a/src/mirall/utility.cpp b/src/mirall/utility.cpp
index 65dc87f07..cee8c3998 100644
--- a/src/mirall/utility.cpp
+++ b/src/mirall/utility.cpp
@@ -345,4 +345,17 @@ QString Utility::compactFormatDouble(double value, int prec, const QString& unit
return str;
}
+QString Utility::toCSyncScheme(const QString &urlStr)
+{
+
+ QUrl url( urlStr );
+ if( url.scheme() == QLatin1String("http") ) {
+ url.setScheme( QLatin1String("owncloud") );
+ } else {
+ // connect SSL!
+ url.setScheme( QLatin1String("ownclouds") );
+ }
+ return url.toString();
+}
+
} // namespace Mirall
diff --git a/src/mirall/utility.h b/src/mirall/utility.h
index 4bed2f15c..46022c725 100644
--- a/src/mirall/utility.h
+++ b/src/mirall/utility.h
@@ -32,6 +32,7 @@ namespace Utility
bool hasLaunchOnStartup(const QString &appName);
void setLaunchOnStartup(const QString &appName, const QString& guiName, bool launch);
qint64 freeDiskSpace(const QString &path, bool *ok = 0);
+ QString toCSyncScheme(const QString &urlStr);
/** Like QLocale::toString(double, 'f', prec), but drops trailing zeros after the decimal point */
/**