Project

General

Profile

Actions

Task #843

closed

Script backup may produce invalid XML

Added by Petr Fišer about 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Ondřej Kopr
Category:
Scripts
Target version:
Start date:
11/20/2017
Due date:
% Done:

100%

Estimated time:
Owner:

Description

When backing up script from the library, invalid xml file can sometimes be produced.
This boils down to using generics in the script, consider this (the script does nothing useful, but it contains reproducible case for reported bug):

import org.joda.time.LocalDate;
import eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto;
List<IdmIdentityContractDto> contracts = identityContractService.findAllValidForDate(entity.getId(),new LocalDate(),null);
if (contracts == null) {
    return 1;
}
return 0;

Resulting XML looks like:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<script>
    <allowClasses>
        <allowClass>
            <className>org.joda.time.LocalDate</className>
        </allowClass>
        <allowClass>
            <className>eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto</className>
        </allowClass>
        <allowClass>
            <className>eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto</className>
        </allowClass>
    </allowClasses>
    <body>import org.joda.time.LocalDate;
import eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto;
List<IdmIdentityContractDto> contracts = identityContractService.findAllValidForDate(entity.getId(),new LocalDate(),null);
if (contracts == null) {
    return 1;
}
return 0;</body>
    <category>TRANSFORM_TO</category>
    somescript
<description><p><br></p></description>
<name>Somescript</name>
<services>
<service>
<name>identityContractService</name>
</service>
<service>
<name>formService</name>
</service>
</services>
<type>groovy</type>
</script>

Note the orphaned tag <IdmIdentityContractDto> which was generics in the code. However now it is creating malformed XML document.
Possible resolutions:
  • Wrap script body in the CDATA tags.
  • Upon backup, convert every < and > in the script body into & lt; and & gt;. Convert it to < and > upon import.

Assigning to Ondra, reassign as needed. :)

Actions

Also available in: Atom PDF