Removing invalid characters from XML backups

JIRA 3.1 and above should not suffer from this problem unless migrating to postgreSQL from another database such as MySQL. Invalid characters otherwise are automatically stripped from imported data.

In older versions of JIRA it was possible to cut & paste text containing control characters into JIRA issue fields. This causes problems, because JIRA's backup format is XML, and XML does not allow for the storage of most control characters.When XML containing control characters is imported into JIRA, the import fails with an error:

To fix this, the control characters will need to be removed from the JIRA backup file. This can be done with the following:

  1. Download atlassian-xml-cleaner-0.1.jar
  2. Open a command prompt and locate the XML or ZIP backup file on your computer, ensuring that it is extracted if it's within a ZIP file. In this example, we will use entities.xml.
  3. Run the application with the below:

    java -jar atlassian-xml-cleaner-0.1.jar entities.xml > entities-clean.xml

    This will create a copy of entities.xml as entities-clean.xml with the invalid characters removed. 

  4. Copy the entities-clean.xml file into another directory, rename it back to entities.xml and create a new ZIP with the newly created entities.xml file and the activeobjects.xml file.
  5. Import the new ZIP file, ensuring that it contains both XML files.

If you are seeing an error specifically with 0xffff as the affected character, please use this perl command to fix the file:

perl -i -pe 's/\xef\xbf\xbf//g' entities.xml

And if experiencing the error with 0xfffe, use the below perl command:

perl -i -pe 's/\xef\xbf\xbe//g' entities.xml

The problem could be caused due to bug  JRA-62240 - Backups created from JIRA Cloud generate 'invalid XML character' and fails when imported back into Cloud. Verified

Was this helpful?

Thanks for your feedback!

Why was this unhelpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport