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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Invalid
    • Affects Version/s: 5.5.1, 5.9.9
    • Fix Version/s: None
    • Component/s: Core: I/O
    • Labels:
      None
    • Platform/s:
      Linux/X11

      Description

      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.

        Attachments

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

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes