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

lupdate does not encode the values in the id attribute

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.5.1, 5.6.1
    • Tools: Linguist
    • Windows 7, mingw version of Qt5.5.x and Qt5.6.x

    Description

      When using qsTrId in qml file, the lupdate will take the value as is and put it in the id= attribute without encoding it.
      This results in a .ts file that is invalid, when the value contains invalid XML characters, like an &.
      Running lupdate a second time will give an error on the file lupdate itself created.

      Example QML file:

      import QtQuick 2.0
      
      Text {
           //% "This text will fail in lupdate"
           text: qsTrId("this&that_will_fail")
      }
      

      run lupdate creates a file containing:

      <?xml version="1.0" encoding="utf-8"?>
      <!DOCTYPE TS>
      <TS version="2.1">
      <context>
          <name></name>
          <message id="this&that_will_fail">
              <location filename="test.qml" line="5"/>
              <source>This text will fail in lupdate</source>
              <translation type="unfinished"></translation>
          </message>
      </context>
      </TS>
      

      Running lupdate againon the with the same ts file will result in the following error:

      lupdate . -ts languagestrings.ts
      Scanning directory '.'...
      Parse error at languagestrings.ts:6:37: Expected ';', but got '"'.
      

      I would not expect lupdate to ever generate invalid output files.
      I could not find any restrictions on the characters that are allowed to be used in the qsTrId.

      Attachments

        Issue Links

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

          Activity

            People

              kkohne Kai Köhne
              japiekrekel Michel van Wonderen
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes