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

QSettings ini file parser does not handle indentation after comment

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.12.1
    • 5.9.0, 5.10.1
    • Core: I/O
    • None
    • All
    • 962bded90f0ffb7390b4a2a1a5a895156aa5f541 (qt/qtbase/5.12)

    Description

      after a line containing a comment, the next line's leading whitespace is not removed.

      bug is in qtbase\src\corelib\io\qsettings.cpp, function readIniLine.

      comment is consumed at line 1626 of qsettings.cpp (5.9.0):

      while (i < dataLen && (((ch = data.at) != '\n') && ch != '\r'))

      but whitespace is only consumed at the start of the function.

       

      Minimum example to reproduce:

       

      #include <QSettings>
      
      int main(int argc, char *argv[])
      {
      	QSettings ini("test.ini", QSettings::IniFormat);
      	ini.beginGroup("FOO");
      	bool ok;
      	ini.value("bar").toInt(&ok);
      	Q_ASSERT(ok);
      }
      

      working test.ini file:

       

       

      [FOO]
      ;bar = 1
      bar = 2
      

      non-working:

       

       

      [FOO]
      ;bar = 1
      	bar = 2
      

       

       

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            __macs Maximilian Schorr
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes