Verify that all strings are properly escaped (#5558)
authorOlivier Goffart <olivier@woboq.com>
Thu, 23 Feb 2017 13:54:17 +0000 (14:54 +0100)
committerMarkus Goetz <markus@woboq.com>
Thu, 23 Feb 2017 13:54:17 +0000 (14:54 +0100)
- I checked every occurence of a '%2' and make correct use of the
QString::arg overload that takes several argument instead of chaining
them, because the first argument can contains a '%1'

 - I tried to look for every label that they either use plain text or richtext
and escape the user provided strings in there.

31 files changed:
src/gui/accountsettings.cpp
src/gui/accountsettings.ui
src/gui/activityitemdelegate.cpp
src/gui/activitywidget.ui
src/gui/authenticationdialog.cpp
src/gui/folder.cpp
src/gui/folderstatusmodel.cpp
src/gui/folderwizard.cpp
src/gui/folderwizardsourcepage.ui
src/gui/folderwizardtargetpage.ui
src/gui/owncloudsetuppage.ui
src/gui/owncloudsetupwizard.cpp
src/gui/protocolwidget.ui
src/gui/proxyauthdialog.ui
src/gui/proxyauthhandler.cpp
src/gui/settingsdialog.cpp
src/gui/sharedialog.ui
src/gui/sharelinkwidget.cpp
src/gui/sharelinkwidget.ui
src/gui/sharemanager.cpp
src/gui/shareusergroupwidget.ui
src/gui/sharewidget.ui
src/gui/sslbutton.cpp
src/gui/updater/ocupdater.cpp
src/gui/wizard/owncloudadvancedsetuppage.cpp
src/gui/wizard/owncloudadvancedsetuppage.ui
src/gui/wizard/owncloudhttpcredspage.ui
src/gui/wizard/owncloudsetupnocredspage.ui
src/libsync/configfile.cpp
src/libsync/owncloudtheme.cpp
src/libsync/utility.cpp

index 0fb32cfbf946a505d7681b079b1b2bf251e4fa02..48bbb496b1d1657aa3553e86960f0c3dc6bf10fb 100644 (file)
@@ -552,10 +552,12 @@ void AccountSettings::slotAccountStateChanged(int state)
             _model->slotUpdateFolderState(folder);
         }
 
-        QString server = QString::fromLatin1("<a href=\"%1\">%2</a>").arg(account->url().toString(), safeUrl.toString());
+        QString server = QString::fromLatin1("<a href=\"%1\">%2</a>")
+                             .arg(Utility::escape(account->url().toString()),
+                                  Utility::escape(safeUrl.toString()));
         QString serverWithUser = server;
         if (AbstractCredentials *cred = account->credentials()) {
-           serverWithUser = tr("%1 as <i>%2</i>").arg(server, cred->user());
+            serverWithUser = tr("%1 as <i>%2</i>").arg(server, Utility::escape(cred->user()));
         }
 
         if (state == AccountState::Connected) {
@@ -569,13 +571,14 @@ void AccountSettings::slotAccountStateChanged(int state)
         } else if (state == AccountState::SignedOut) {
             showConnectionLabel( tr("Signed out from %1.").arg(serverWithUser) );
         } else {
-            showConnectionLabel( tr("No connection to %1 at %2.")
-                                 .arg(Theme::instance()->appNameGUI(),
-                                      server), _accountState->connectionErrors() );
+            showConnectionLabel(tr("No connection to %1 at %2.")
+                                    .arg(Utility::escape(Theme::instance()->appNameGUI()), server),
+                                _accountState->connectionErrors());
         }
     } else {
         // ownCloud is not yet configured.
-        showConnectionLabel( tr("No %1 connection configured.").arg(Theme::instance()->appNameGUI()) );
+        showConnectionLabel(tr("No %1 connection configured.")
+                                .arg(Utility::escape(Theme::instance()->appNameGUI())));
     }
 
     /* Allow to expand the item if the account is connected. */
@@ -664,7 +667,8 @@ void AccountSettings::refreshSelectiveSyncStatus()
             }
             QModelIndex theIndx = _model->indexForPath(folder, myFolder);
             if(theIndx.isValid()) {
-                msg += QString::fromLatin1("<a href=\"%1?folder=%2\">%1</a>").arg(myFolder).arg(folder->alias());
+                msg += QString::fromLatin1("<a href=\"%1?folder=%2\">%1</a>")
+                           .arg(Utility::escape(myFolder), Utility::escape(folder->alias()));
             } else {
                 msg += myFolder; // no link because we do not know the index yet.
             }
index f100d37526f1f14a768a5c9e2ef5f36a6f360d55..bae5d945f5d32e7b066684379c13ca3aaa6eb804 100644 (file)
@@ -41,6 +41,9 @@
         <property name="text">
          <string>Connected with &lt;server&gt; as &lt;user&gt;</string>
         </property>
+        <property name="textFormat">
+         <enum>Qt::RichText</enum>
+        </property>
         <property name="wordWrap">
          <bool>true</bool>
         </property>
@@ -75,6 +78,9 @@
        <property name="text">
         <string>Storage space: ...</string>
        </property>
+       <property name="textFormat">
+        <enum>Qt::PlainText</enum>
+       </property>
        <property name="wordWrap">
         <bool>false</bool>
        </property>
           <property name="text">
            <string>Unchecked folders will be &lt;b&gt;removed&lt;/b&gt; from your local file system and will not be synchronized to this computer anymore</string>
           </property>
+          <property name="textFormat">
+           <enum>Qt::RichText</enum>
+          </property>
           <property name="wordWrap">
            <bool>true</bool>
           </property>
index e625b973673e94965fdf906536b44d07f180e1a0..171b5895e482eb0ae1a049c9ddf02b218ec5afb7 100644 (file)
@@ -142,9 +142,9 @@ void ActivityItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
 
     QString timeStr;
     if ( accountOnline ) {
-        timeStr = tr("%1 on %2").arg(timeText).arg(accountRole);
+        timeStr = tr("%1 on %2").arg(timeTextaccountRole);
     } else {
-        timeStr = tr("%1 on %2 (disconnected)").arg(timeText).arg(accountRole);
+        timeStr = tr("%1 on %2 (disconnected)").arg(timeTextaccountRole);
         QPalette p = option.palette;
         painter->setPen(p.color(QPalette::Disabled, QPalette::Text));
     }
index 79d9a963bc2bdeb42ce3ac2fe4c15546a8535e7c..97765347aaa888aab2075411ab148f6d13f67a3e 100644 (file)
@@ -25,6 +25,9 @@
      <property name="text">
       <string>TextLabel</string>
      </property>
+     <property name="textFormat">
+      <enum>Qt::PlainText</enum>
+     </property>
     </widget>
    </item>
    <item row="1" column="0">
@@ -64,6 +67,9 @@
      <property name="text">
       <string>TextLabel</string>
      </property>
+     <property name="textFormat">
+      <enum>Qt::RichText</enum>
+     </property>
     </widget>
    </item>
    <item row="3" column="0">
@@ -87,6 +93,9 @@
      <property name="text">
       <string>TextLabel</string>
      </property>
+     <property name="textFormat">
+      <enum>Qt::RichText</enum>
+     </property>
     </widget>
    </item>
    <item row="5" column="0">
index 70f901e0638022678abbdca3afd49a820158ed24..1d05e7264372f5db1d838120c1674eb6693f1cf0 100644 (file)
@@ -30,6 +30,7 @@ AuthenticationDialog::AuthenticationDialog(const QString &realm, const QString &
     setWindowTitle(tr("Authentication Required"));
     QVBoxLayout *lay = new QVBoxLayout(this);
     QLabel *label = new QLabel(tr("Enter username and password for '%1' at %2.").arg(realm, domain));
+    label->setTextFormat(Qt::PlainText);
     lay->addWidget(label);
 
     QFormLayout *form = new QFormLayout;
index 4eae28f67688c92845a99e1850ca4bc26dc6feae..18d2f2b12f7e8d386f037dfe9f896a30caa4d05f 100644 (file)
@@ -383,16 +383,16 @@ void Folder::createGuiLog( const QString& filename, LogStatus status, int count,
             break;
         case LogStatusRename:
             if( count > 1 ) {
-                text = tr("%1 has been renamed to %2 and %n other file(s) have been renamed.", "", count-1).arg(file).arg(renameTarget);
+                text = tr("%1 has been renamed to %2 and %n other file(s) have been renamed.", "", count-1).arg(filerenameTarget);
             } else {
-                text = tr("%1 has been renamed to %2.", "%1 and %2 name files.").arg(file).arg(renameTarget);
+                text = tr("%1 has been renamed to %2.", "%1 and %2 name files.").arg(filerenameTarget);
             }
             break;
         case LogStatusMove:
             if( count > 1 ) {
-                text = tr("%1 has been moved to %2 and %n other file(s) have been moved.", "", count-1).arg(file).arg(renameTarget);
+                text = tr("%1 has been moved to %2 and %n other file(s) have been moved.", "", count-1).arg(filerenameTarget);
             } else {
-                text = tr("%1 has been moved to %2.").arg(file).arg(renameTarget);
+                text = tr("%1 has been moved to %2.").arg(filerenameTarget);
             }
             break;
         case LogStatusConflict:
index ebd9ab0b734580872d824fde7d5d5ae848e8ee67..65ff918d5bb88210dc7eedec0a4f12f8eb023bf0 100644 (file)
@@ -164,10 +164,11 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
     {
         const auto &x = static_cast<SubFolderInfo *>(index.internalPointer())->_subs[index.row()];
         switch (role) {
-        case Qt::ToolTipRole:
         case Qt::DisplayRole:
             //: Example text: "File.txt (23KB)"
             return x._size < 0 ? x._name : tr("%1 (%2)").arg(x._name, Utility::octetsToString(x._size));
+        case Qt::ToolTipRole:
+            return QString(QLatin1String("<qt>") + Utility::escape(x._size < 0 ? x._name : tr("%1 (%2)").arg(x._name, Utility::octetsToString(x._size))) + QLatin1String("</qt>"));
         case Qt::CheckStateRole:
             return x._checked;
         case Qt::DecorationRole:
index b786591c0807e4553dce68790e93573174bac082..8a15c873947ab1257548641a6ea20ad9452e794f 100644 (file)
@@ -65,7 +65,7 @@ FolderWizardLocalPath::FolderWizardLocalPath(const AccountPtr& account)
     connect(_ui.localFolderChooseBtn, SIGNAL(clicked()), this, SLOT(slotChooseLocalFolder()));
     _ui.localFolderChooseBtn->setToolTip(tr("Click to select a local folder to sync."));
 
-    QString defaultPath = QString::fromLatin1( "%1/%2").arg( QDir::homePath() ).arg(Theme::instance()->appName() );
+    QString defaultPath = QDir::homePath() + QLatin1Char('/') + Theme::instance()->appName();
     _ui.localFolderLineEdit->setText( QDir::toNativeSeparators( defaultPath ) );
     _ui.localFolderLineEdit->setToolTip(tr("Enter the path to the local folder."));
 
@@ -441,7 +441,8 @@ bool FolderWizardRemotePath::isComplete() const
         if (QDir::cleanPath(dir) == QDir::cleanPath(curDir)) {
             warnStrings.append(tr("This folder is already being synced."));
         } else if (dir.startsWith(curDir + QLatin1Char('/'))) {
-            warnStrings.append(tr("You are already syncing <i>%1</i>, which is a parent folder of <i>%2</i>.").arg(curDir).arg(dir));
+            warnStrings.append(tr("You are already syncing <i>%1</i>, which is a parent folder of <i>%2</i>.").arg(
+                Utility::escape(curDir), Utility::escape(dir)));
         }
 
         if (curDir == QLatin1String("/")) {
index cccb4c1643166e7e38472113cf82461a4fcf203b..7522792be327da3800dd89aacc2d058440ac13f9 100644 (file)
       <string/>
      </property>
      <property name="textFormat">
-      <enum>Qt::AutoText</enum>
+      <enum>Qt::RichText</enum>
      </property>
      <property name="margin">
       <number>3</number>
index 0a9ad5aa973b0b2b0ec55990d636b9ecae2d8f6f..5dcefc73f6062cfeb6c93816e173216b060225e6 100644 (file)
            <string>TextLabel</string>
           </property>
           <property name="textFormat">
-           <enum>Qt::AutoText</enum>
+           <enum>Qt::RichText</enum>
           </property>
           <property name="wordWrap">
            <bool>true</bool>
index 6190119d027b34220f29028cf5429be8a69d5f9d..8ae99d3513504d8a3c9a6a4a0967a6af04404a24 100644 (file)
@@ -35,6 +35,9 @@
      <property name="text">
       <string>TextLabel</string>
      </property>
+     <property name="textFormat">
+      <enum>Qt::RichText</enum>
+     </property>
     </widget>
    </item>
    <item row="3" column="0" colspan="2">
      <property name="text">
       <string>TextLabel</string>
      </property>
+     <property name="textFormat">
+      <enum>Qt::RichText</enum>
+     </property>
     </widget>
    </item>
    <item row="5" column="1">
index bf67c9acfb800d8e705e7853832513db4c955dae..53e360e414097c4e1a2cf206f15f83b3e99b97d5 100644 (file)
@@ -178,10 +178,10 @@ void OwncloudSetupWizard::slotOwnCloudFoundAuth(const QUrl& url, const QVariantM
     auto serverVersion = CheckServerJob::version(info);
 
     _ocWizard->appendToConfigurationLog(tr("<font color=\"green\">Successfully connected to %1: %2 version %3 (%4)</font><br/><br/>")
-                                        .arg(url.toString())
-                                        .arg(Theme::instance()->appNameGUI())
-                                        .arg(CheckServerJob::versionString(info))
-                                        .arg(serverVersion));
+                                        .arg(Utility::escape(url.toString()),
+                                             Utility::escape(Theme::instance()->appNameGUI()),
+                                             Utility::escape(CheckServerJob::versionString(info)),
+                                             Utility::escape(serverVersion)));
 
     _ocWizard->account()->setServerVersion(serverVersion);
 
@@ -212,9 +212,9 @@ void OwncloudSetupWizard::slotNoOwnCloudFoundAuth(QNetworkReply *reply)
         msg = tr("Invalid URL");
     } else {
         msg = tr("Failed to connect to %1 at %2:<br/>%3")
-            .arg(Theme::instance()->appNameGUI(),
-                 reply->url().toString(),
-                 reply->errorString());
+                  .arg(Utility::escape(Theme::instance()->appNameGUI()),
+                       Utility::escape(reply->url().toString()),
+                       Utility::escape(reply->errorString()));
     }
     bool isDowngradeAdvised = checkDowngradeAdvised(reply);
 
@@ -244,9 +244,10 @@ void OwncloudSetupWizard::slotNoOwnCloudFoundAuth(QNetworkReply *reply)
 
 void OwncloudSetupWizard::slotNoOwnCloudFoundAuthTimeout(const QUrl&url)
 {
-    _ocWizard->displayError(tr("Timeout while trying to connect to %1 at %2.")
-                            .arg(Theme::instance()->appNameGUI(),
-                                 url.toString()), false);
+    _ocWizard->displayError(
+        tr("Timeout while trying to connect to %1 at %2.")
+            .arg(Utility::escape(Theme::instance()->appNameGUI()), Utility::escape(url.toString())),
+        false);
 }
 
 void OwncloudSetupWizard::slotConnectToOCUrl( const QString& url )
@@ -307,7 +308,7 @@ void OwncloudSetupWizard::slotAuthError()
         }
         errorMsg = tr("The authenticated request to the server was redirected to "
                       "'%1'. The URL is bad, the server is misconfigured.")
-                   .arg(redirectUrl.toString());
+                       .arg(Utility::escape(redirectUrl.toString()));
 
     // A 404 is actually a success: we were authorized to know that the folder does
     // not exist. It will be created later...
@@ -320,7 +321,7 @@ void OwncloudSetupWizard::slotAuthError()
         if (!_ocWizard->account()->credentials()->stillValid(reply)) {
             errorMsg = tr("Access forbidden by server. To verify that you have proper access, "
                           "<a href=\"%1\">click here</a> to access the service with your browser.")
-                       .arg(_ocWizard->account()->url().toString());
+                           .arg(Utility::escape(_ocWizard->account()->url().toString()));
         } else {
             errorMsg = errorMessage(reply->errorString(), reply->readAll());
         }
@@ -369,7 +370,9 @@ void OwncloudSetupWizard::slotCreateLocalAndRemoteFolders(const QString& localFo
     if( fi.exists() ) {
         // there is an existing local folder. If its non empty, it can only be synced if the
         // ownCloud is newly created.
-        _ocWizard->appendToConfigurationLog( tr("Local sync folder %1 already exists, setting it up for sync.<br/><br/>").arg(localFolder));
+        _ocWizard->appendToConfigurationLog(
+            tr("Local sync folder %1 already exists, setting it up for sync.<br/><br/>")
+                .arg(Utility::escape(localFolder)));
     } else {
         QString res = tr("Creating local sync folder %1...").arg(localFolder);
         if( fi.mkpath( localFolder ) ) {
@@ -379,7 +382,7 @@ void OwncloudSetupWizard::slotCreateLocalAndRemoteFolders(const QString& localFo
         } else {
             res += tr("failed.");
             qDebug() << "Failed to create " << fi.path();
-            _ocWizard->displayError(tr("Could not create local folder %1").arg(localFolder), false);
+            _ocWizard->displayError(tr("Could not create local folder %1").arg(Utility::escape(localFolder)), false);
             nextStep = false;
         }
         _ocWizard->appendToConfigurationLog( res );
@@ -415,7 +418,7 @@ void OwncloudSetupWizard::slotRemoteFolderExists(QNetworkReply *reply)
     }
 
     if( !ok ) {
-        _ocWizard->displayError(error, false);
+        _ocWizard->displayError(Utility::escape(error), false);
     }
 
     finalizeSetup( ok );
@@ -455,8 +458,8 @@ void OwncloudSetupWizard::slotCreateRemoteFolderFinished( QNetworkReply::Network
         _remoteFolder.clear();
         success = false;
     } else {
-        _ocWizard->appendToConfigurationLog( tr("Remote folder %1 creation failed with error <tt>%2</tt>.").arg(_remoteFolder).arg(error));
-        _ocWizard->displayError( tr("Remote folder %1 creation failed with error <tt>%2</tt>.").arg(_remoteFolder).arg(error), false );
+        _ocWizard->appendToConfigurationLog( tr("Remote folder %1 creation failed with error <tt>%2</tt>.").arg(Utility::escape(_remoteFolder)).arg(error));
+        _ocWizard->displayError( tr("Remote folder %1 creation failed with error <tt>%2</tt>.").arg(Utility::escape(_remoteFolder)).arg(error), false );
         _remoteFolder.clear();
         success = false;
     }
@@ -472,8 +475,9 @@ void OwncloudSetupWizard::finalizeSetup( bool success )
     const QString localFolder = _ocWizard->property("localFolder").toString();
     if( success ) {
         if( !(localFolder.isEmpty() || _remoteFolder.isEmpty() )) {
-            _ocWizard->appendToConfigurationLog( tr("A sync connection from %1 to remote directory %2 was set up.")
-                                                 .arg(localFolder).arg(_remoteFolder));
+            _ocWizard->appendToConfigurationLog(
+                tr("A sync connection from %1 to remote directory %2 was set up.")
+                    .arg(localFolder, _remoteFolder));
         }
         _ocWizard->appendToConfigurationLog( QLatin1String(" "));
         _ocWizard->appendToConfigurationLog( QLatin1String("<p><font color=\"green\"><b>")
index 247604308095820ee6ce4fecee1d34e6fa5aaa23..143c2d627b667d256d932da498054693ed8ade86 100644 (file)
@@ -19,6 +19,9 @@
      <property name="text">
       <string>TextLabel</string>
      </property>
+     <property name="textFormat">
+      <enum>Qt::PlainText</enum>
+     </property>
     </widget>
    </item>
    <item row="1" column="0" colspan="2">
index d71d392a52a4c097dda13e54eac5befc79a67727..cf640f1b3401a0620675178711432a4dedaecd2b 100644 (file)
@@ -73,6 +73,9 @@
      <property name="text">
       <string>TextLabel</string>
      </property>
+     <property name="textFormat">
+      <enum>Qt::PlainText</enum>
+     </property>
     </widget>
    </item>
   </layout>
index 6d304966ac520f355e610bfcc91e0b9c0d52f812..a3f0fba7e589eb51327a507d01f1de11db4e44d9 100644 (file)
@@ -58,8 +58,7 @@ void ProxyAuthHandler::handleProxyAuthenticationRequired(
         return;
     }
 
-    QString key = QString::fromLatin1("%1:%2").arg(
-            proxy.hostName(), QString::number(proxy.port()));
+    QString key = proxy.hostName() + QLatin1Char(':') + QString::number(proxy.port());
 
     // If the proxy server has changed, forget what we know.
     if (key != _proxy) {
index 499fb3e0afaa468e8fe8425eb40348318c56a3f2..2e084c7ac39708cf0a820755e36de0b6a517c952 100644 (file)
@@ -252,7 +252,7 @@ void SettingsDialog::customizeStyle()
     QString altBase(palette().alternateBase().color().name());
     QString dark(palette().dark().color().name());
     QString background(palette().base().color().name());
-    _toolBar->setStyleSheet(QString::fromAscii(TOOLBAR_CSS).arg(background).arg(dark).arg(highlightColor).arg(altBase));
+    _toolBar->setStyleSheet(QString::fromAscii(TOOLBAR_CSS).arg(background,dark,highlightColor,altBase));
 
     Q_FOREACH(QAction *a, _actionGroup->actions()) {
         QIcon icon = createColorAwareIcon(a->property("iconPath").toString());
index 7b5fca8b888ef9f366d7e25f0ad8920c3dd71b0e..051a526ba3b7fee5f828a9384791d7b7658fb221 100644 (file)
@@ -27,6 +27,9 @@
        <property name="text">
         <string>share label</string>
        </property>
+       <property name="textFormat">
+        <enum>Qt::PlainText</enum>
+       </property>
       </widget>
      </item>
      <item row="1" column="1">
@@ -46,6 +49,9 @@
        <property name="text">
         <string>ownCloud Path:</string>
        </property>
+       <property name="textFormat">
+        <enum>Qt::PlainText</enum>
+       </property>
       </widget>
      </item>
      <item row="0" column="0" rowspan="2">
index 116cea703aaf5ad3911d0c7d5ecc007f825bb90f..456c02be7bc305c4bbdbde309db763ddff6995b2 100644 (file)
@@ -321,7 +321,7 @@ void ShareLinkWidget::redrawElidedUrl()
         const QUrl realUrl(_shareUrl);
         QString elidedUrl = fm.elidedText(_shareUrl, Qt::ElideRight, linkLengthPixel);
 
-        u = QString("<a href=\"%1\">%2</a>").arg(realUrl.toString(QUrl::None)).arg(elidedUrl);
+        u = QString("<a href=\"%1\">%2</a>").arg(Utility::escape(realUrl.toString(QUrl::None)), Utility::escape(elidedUrl));
     }
     _ui->_labelShareLink->setText(u);
 }
index 718207488e5c29432a7243b2d65424f9ab495778..581887e19e09e2b21a7719d15956fc504c49ccd9 100644 (file)
@@ -76,6 +76,9 @@
      <property name="text">
       <string>TextLabel</string>
      </property>
+     <property name="textFormat">
+      <enum>Qt::PlainText</enum>
+     </property>
     </widget>
    </item>
    <item row="1" column="0" colspan="2">
index 406626d3bfc5984ad9f26df18281e27b742c5d6c..08f2092d5bdc02b2251ad0f0d71ccc84eb9c5378 100644 (file)
@@ -345,7 +345,7 @@ QSharedPointer<LinkShare> ShareManager::parseLinkShare(const QVariantMap &data)
         url = QUrl(data.value("url").toString());
     } else if (_account->serverVersionInt() >= (8 << 16)) {
         // From ownCloud server version 8 on, a different share link scheme is used.
-        url = QUrl(Utility::concatUrlPath(_account->url(), QString("index.php/s/%1").arg(data.value("token").toString())).toString());
+        url = QUrl(Utility::concatUrlPath(_account->url(), QLatin1String("index.php/s/") + data.value("token").toString())).toString();
     } else {
         QList<QPair<QString, QString>> queryArgs;
         queryArgs.append(qMakePair(QString("service"), QString("files")));
index 79ca850f021aea6c6da1dbda68423633fedc3ae1..9122fef05258b340d75cf139de67a7f2c2fa205a 100644 (file)
@@ -67,6 +67,9 @@
      <property name="text">
       <string notr="true">Placeholder for Error text</string>
      </property>
+     <property name="textFormat">
+      <enum>Qt::PlainText</enum>
+     </property>
      <property name="wordWrap">
       <bool>true</bool>
      </property>
index a6b044590c308c9590f2a318033b66226fe72868..02d1c70400097c9a918bde201cab1234847ace17 100644 (file)
@@ -36,6 +36,9 @@
        <property name="text">
         <string>TextLabel</string>
        </property>
+       <property name="textFormat">
+        <enum>Qt::PlainText</enum>
+       </property>
       </widget>
      </item>
      <item>
index 93b157f1c82b5d492afef16f6993fd702362af7a..7fe0ec052caf3e79cfbf07a257c67b5aa4c43a54 100644 (file)
@@ -58,7 +58,9 @@ static QString addCertDetailsField(const QString &key, const QString &value)
     if (value.isEmpty())
         return QString();
 
-    return QString::fromLatin1("<tr><td style=\"vertical-align: top;\"><b>%1</b></td><td style=\"vertical-align: bottom;\">%2</td></tr>").arg(key).arg(value);
+    return QLatin1String("<tr><td style=\"vertical-align: top;\"><b>") + key
+        + QLatin1String("</b></td><td style=\"vertical-align: bottom;\">)") + value
+        + QLatin1String("</td></tr>");
 }
 
 
@@ -162,7 +164,9 @@ QMenu* SslButton::buildCertMenu(QMenu *parent, const QSslCertificate& cert,
     // create label first
     QLabel *label = new QLabel(parent);
     label->setStyleSheet(QLatin1String("QLabel { padding: 8px; background-color: #fff; }"));
+    label->setTextFormat(Qt::RichText);
     label->setText(details);
+
     // plug label into widget action
     QWidgetAction *action = new QWidgetAction(parent);
     action->setDefaultWidget(label);
index b6aa88c455d481327a25a4516f5ab6ee698ce839..18a4cf53c629145b9ed541a5afb0cb31aa5e4dd3 100644 (file)
@@ -339,7 +339,8 @@ void NSISUpdater::showDialog(const UpdateInfo &info)
     QLabel *lbl = new QLabel;
     QString txt = tr("<p>A new version of the %1 Client is available.</p>"
                      "<p><b>%2</b> is available for download. The installed version is %3.</p>")
-            .arg(Theme::instance()->appNameGUI()).arg(info.versionString()).arg(clientVersion());
+                      .arg(Utility::escape(Theme::instance()->appNameGUI()),
+                           Utility::escape(info.versionString()), Utility::escape(clientVersion()));
 
     lbl->setText(txt);
     lbl->setTextFormat(Qt::RichText);
index 8de9ee339a56e1be6a91a3613327f70777084ac9..5a3c566419cd70e47cfeaa1135a53c97aa73cc13 100644 (file)
@@ -156,10 +156,10 @@ void OwncloudAdvancedSetupPage::updateStatus()
         if( _remoteFolder.isEmpty() || _remoteFolder == QLatin1String("/") ) {
             t = "";
         } else {
-            t = tr("%1 folder '%2' is synced to local folder '%3'")
-                .arg(Theme::instance()->appName()).arg(_remoteFolder)
-                .arg(QDir::toNativeSeparators(locFolder));
-              _ui.rSyncEverything->setText(tr("Sync the folder '%1'").arg(_remoteFolder));
+            t = Utility::escape(tr("%1 folder '%2' is synced to local folder '%3'")
+                                    .arg(Theme::instance()->appName(), _remoteFolder,
+                                         QDir::toNativeSeparators(locFolder)));
+            _ui.rSyncEverything->setText(tr("Sync the folder '%1'").arg(_remoteFolder));
         }
 
         const bool dirNotEmpty(QDir(locFolder).entryList(QDir::AllEntries | QDir::NoDotAndDotDot).count() > 0);
index ccf891d967b8adc56d544d8b41edbc9177e1e4c6..a36704c389cfd9e4635953945b0e0e87982fdc63 100644 (file)
@@ -31,6 +31,9 @@
      <property name="text">
       <string>TextLabel</string>
      </property>
+     <property name="textFormat">
+      <enum>Qt::RichText</enum>
+     </property>
      <property name="alignment">
       <set>Qt::AlignCenter</set>
      </property>
             <property name="text">
              <string>TextLabel</string>
             </property>
+            <property name="textFormat">
+             <enum>Qt::PlainText</enum>
+            </property>
            </widget>
           </item>
           <item>
             <property name="text">
              <string>TextLabel</string>
             </property>
+            <property name="textFormat">
+             <enum>Qt::PlainText</enum>
+            </property>
            </widget>
           </item>
           <item>
      <property name="text">
       <string>Status message</string>
      </property>
+     <property name="textFormat">
+      <enum>Qt::RichText</enum>
+     </property>
      <property name="alignment">
       <set>Qt::AlignCenter</set>
      </property>
      <property name="text">
       <string>TextLabel</string>
      </property>
+     <property name="textFormat">
+      <enum>Qt::RichText</enum>
+     </property>
     </widget>
    </item>
   </layout>
index 0af5e559725a5b26583f8158a4d963be25be9771..9fd445f35b3566a12b6dc44a22945ccd1aa0bc6e 100644 (file)
@@ -22,6 +22,9 @@
      <property name="text">
       <string notr="true">TextLabel</string>
      </property>
+     <property name="textFormat">
+      <enum>Qt::RichText</enum>
+     </property>
      <property name="alignment">
       <set>Qt::AlignCenter</set>
      </property>
@@ -89,6 +92,9 @@
        <property name="text">
         <string notr="true">Error Label</string>
        </property>
+       <property name="textFormat">
+        <enum>Qt::RichText</enum>
+       </property>
        <property name="openExternalLinks">
         <bool>true</bool>
        </property>
      <property name="text">
       <string notr="true">TextLabel</string>
      </property>
+     <property name="textFormat">
+      <enum>Qt::RichText</enum>
+     </property>
     </widget>
    </item>
    <item row="1" column="1">
      <property name="text">
       <string notr="true">TextLabel</string>
      </property>
+     <property name="textFormat">
+      <enum>Qt::RichText</enum>
+     </property>
      <property name="wordWrap">
       <bool>true</bool>
      </property>
index cbeeb5246fdee23b5c703b6dc204576db172b048..8b00cb5705e7111a039d5d34c8dfb34e9947db96 100644 (file)
@@ -31,6 +31,9 @@
      <property name="text">
       <string>TextLabel</string>
      </property>
+     <property name="textFormat">
+      <enum>Qt::RichText</enum>
+     </property>
      <property name="alignment">
       <set>Qt::AlignCenter</set>
      </property>
      <property name="text">
       <string>Error Label</string>
      </property>
+     <property name="textFormat">
+      <enum>Qt::RichText</enum>
+     </property>
      <property name="openExternalLinks">
       <bool>true</bool>
      </property>
      <property name="text">
       <string>TextLabel</string>
      </property>
+     <property name="textFormat">
+      <enum>Qt::RichText</enum>
+     </property>
     </widget>
    </item>
   </layout>
index 39f6303f6e6169ddf50bf935546358988390d35c..2132ced728a7db0e86936f08367d2ab29d576821 100644 (file)
@@ -185,14 +185,14 @@ QVariant ConfigFile::getPolicySetting(const QString &setting, const QVariant& de
     if (Utility::isWindows()) {
         // check for policies first and return immediately if a value is found.
         QSettings userPolicy(QString::fromLatin1("HKEY_CURRENT_USER\\Software\\Policies\\%1\\%2")
-                             .arg(APPLICATION_VENDOR).arg(Theme::instance()->appName()),
+                             .arg(APPLICATION_VENDORTheme::instance()->appName()),
                              QSettings::NativeFormat);
         if(userPolicy.contains(setting)) {
             return userPolicy.value(setting);
         }
 
         QSettings machinePolicy(QString::fromLatin1("HKEY_LOCAL_MACHINE\\Software\\Policies\\%1\\%2")
-                                .arg(APPLICATION_VENDOR).arg(APPLICATION_NAME),
+                                .arg(APPLICATION_VENDORAPPLICATION_NAME),
                                 QSettings::NativeFormat);
         if(machinePolicy.contains(setting)) {
             return machinePolicy.value(setting);
@@ -257,7 +257,7 @@ QString ConfigFile::excludeFileFromSystem()
     fi.setFile( QCoreApplication::applicationDirPath(), exclFile );
 #endif
 #ifdef Q_OS_UNIX
-    fi.setFile( QString( SYSCONFDIR "/%1").arg(Theme::instance()->appName()), exclFile );
+    fi.setFile(QString(SYSCONFDIR "/" + Theme::instance()->appName()), exclFile);
     if ( ! fi.exists() ) {
         // Prefer to return the preferred path! Only use the fallback location
         // if the other path does not exist and the fallback is valid.
@@ -489,8 +489,8 @@ QVariant ConfigFile::getValue(const QString& param, const QString& group,
         systemSetting = systemSettings.value(param, defaultValue);
     } else { // Windows
         QSettings systemSettings(QString::fromLatin1("HKEY_LOCAL_MACHINE\\Software\\%1\\%2")
-                                .arg(APPLICATION_VENDOR).arg(Theme::instance()->appName()),
-                                QSettings::NativeFormat);
+                                     .arg(APPLICATION_VENDOR, Theme::instance()->appName()),
+                                 QSettings::NativeFormat);
         if (!group.isEmpty()) {
             systemSettings.beginGroup(group);
         }
index 55ed2261d3f0a45d555af95cfc81628c6a1ad265..7b380570740a2562826936b3426fd614593c8511 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "version.h"
 #include "config.h"
+#include "utility.h"
 
 namespace OCC {
 
@@ -53,9 +54,9 @@ QString ownCloudTheme::about() const
                "ownCloud and the ownCloud Logo are registered trademarks of ownCloud GmbH "
                "in the United States, other countries, or both.</p>"
                )
-            .arg(MIRALL_VERSION_STRING)
-            .arg("https://" MIRALL_STRINGIFY(APPLICATION_DOMAIN))
-            .arg(MIRALL_STRINGIFY(APPLICATION_DOMAIN));
+            .arg(Utility::escape(MIRALL_VERSION_STRING),
+                 Utility::escape("https://" MIRALL_STRINGIFY(APPLICATION_DOMAIN)),
+                 Utility::escape(MIRALL_STRINGIFY(APPLICATION_DOMAIN)));
 
     devString += gitSHA1();
     return devString;
index 052ba1d17a551fe55b995f78182fce25fabedc78..7868aeb5a2d5bd4ecbe145437a02579296a06c7c 100644 (file)
@@ -180,8 +180,7 @@ static QLatin1String platform()
 QByteArray Utility::userAgentString()
 {
     QString re = QString::fromLatin1("Mozilla/5.0 (%1) mirall/%2")
-            .arg(platform())
-            .arg(QLatin1String(MIRALL_VERSION_STRING));
+                     .arg(platform(), QLatin1String(MIRALL_VERSION_STRING));
 
     QLatin1String appName(APPLICATION_SHORTNAME);