mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 09:30:13 +03:00
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.
This commit is contained in:
parent
203b9c7f6b
commit
26bd164168
6 changed files with 22 additions and 22 deletions
|
@ -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;
|
||||
|
|
|
@ -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) ) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue