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

QDIR:: exists() when the file path contains "..", and if the sub file does not exist, its upper level directory is judged to be nonexistent. For example, "local /. / bin", if "bin" does not exist, "local" is judged as nonexistent

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.5.1, 5.9.9
    • Core: I/O
    • None
    • Linux/X11

      In Linux system, QFile::exists() / QDir::exists() / QFile::open() / QDir::rmdir() and other functions have the same problem. If the file path contains "..", when the sub file does not exist, its upper level directory is also determined as nonexistent, such as "local /. / bin". If "bin" does not exist, "local" is judged as nonexistent / cannot be opened / deleted. 

      QDir dir(""/home/hanyi/Work/NoExists/../Tree2"");

      //"/home/hanyi/Work/Tree2" is exist, "NoExists" is not exist 

      bool bValue  = dir.exists(); //return false

       

      In Windows system, it is no problem to transfer parameters in this way. The difference between the two is that: 

      In the QFileSystemEntry::resolveNativeFilePath() function, the 

      QFSFileEnginePrivate::longFileName --》 GetFullPathName correctly handles the path containing.. /. Under Linux system, nothing is done. 

      I understand that in this function, the path containing ".." should be processed by using QDir::cleanPath.

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

            thiago Thiago Macieira
            dongcy Dong Chunyu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes