Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-7620

QProcess start does not handle properly arguments with characters such as ampersands("&"), carets("^") and commas(",")

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.7.0
    • 4.4.3, 4.5.0, 4.5.1, 4.5.2, 4.5.3, 4.6.0, 4.6.1
    • Core: I/O
    • None
    • 4fe7291edcac2688f042a11ff5c23374c6c0375d

    Description

      When a string of a stringlist contains such characters, it is not "quoted" when injected as a command line. To reproduce:

      The batch file (C:\ListDir.bat) only has one line to print out the contents of a directory.

      dir "%~1"

      The Qt code is written like below.

      #include <iostream> 
      #include <QProcess> 
      
      int main(int argc, char *argv[]) 
      { 
      QProcess proc(NULL); 
      proc.start("C:\\ListDir.bat", QStringList() << "C:\\Comma,Directory\\ "); 
      proc.waitForFinished(-1); 
      std::cout << QString(proc.readAllStandardOutput()).toStdString().c_str(); 
      
      return 0; 
      } 
      

      As a result the command executed is "dir c:\Comma". the ",Directory" has been "lost" while "dir "c:\Comma,Directory" is a valid windows command.

      Problem:
      I think in qprocess_win.cpp, function static QString qt_create_commandline(const QString &program, const QStringList &arguments), the problem is that the argument should be quoted whatever characters it contains.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            buddenha Oswald Buddenhagen
            sanonymous Nokia Qt Support (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes