BPM-7073 Error GEL Script in 14.2 when HTML img tag is present

Document ID : KB000030673
Last Modified Date : 14/02/2018
Show Technical Document Details

Problem:

We have an existing process that worked in v13.3, but now in v14.2 it fails or when we try to create a new step on a process with an HTML img tag, the save action on the step generates the following error and the GEL script code is changed by the application.

 BPM-7073: Custom script syntax error at line1, column 2: Reference is not allowed in prolog

Steps to Reproduce

1. Create a process 
2. Create a new step - Use GEL script that has HTML img tag
<gel:script xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary">
<gel:parameter var="XOG_URL" default="http://test:123" />
<gel:parse var="emailMsg">
  <img src="${XOG_URL}/niku/something/something" />
</gel:parse>
<!-- do stuff -->
</gel:script> 
3. Click Save button
  
Expected Result:  Process saves successfully
Actual Result:  Existing, valid process fails if tag is present or saving a step causes an error

Environment: 

Applies to all supported PAS environments for specified releases.  

Cause:

Caused by CLRT-77698

CLRT-77698 is closed and marked as a duplicate to CLRT-77500 

Resolution

Resolved in CA PPM 14.2 Generic Patch #1  

Resolved in CA PPM 14.3  

Workaround: 

The application is attempting to parse the GEL script image 'src' text.  Use a 'src' attribute in the GEL script.

The following script can be used as a demonstration for how to perform a workaround. It shows how to add a src= attribute to the img tag using XSLT.

This is script required to setup and perform an XSL transformation, which processes every element/attribute of some input XML against some XSL templates and keeps/alters each piece as appropriate. that's what it takes, to perform such a task.
<xsl:attribute name="src">

The idea behind the workaround is to first name the attribute something else, then use XSLT to 'copy everything' except for IMG tags which it then treats separately.

Note that if there are other attributes in the IMG tag, in order to bring those across may require an adjustment to the way the XSL templates are defined - this is just an example to prove the workaround for that attribute as a feasible approach.

Note: This is just a demonstration script to show the technique and output, it isn't a refactoring of the original script that would need to be altered to accommodate a similar approach


- Script that demonstrates how to perform a workaround:

<gel:script
xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
xmlns:x="jelly:org.apache.commons.jelly.tags.xml.XMLTagLibrary"
>

<gel:parameter var="XOG_URL" default="http://test:123" />

<gel:parse var="emailMsg">
<img rsc="${XOG_URL}/niku/something/something" />
</gel:parse>

<gel:parse var="src_xsl">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="img" />
<img>
<xsl:attribute name="src">
<xsl:value-of select="@rsc" />
</xsl:attribute>
</img>
</xsl:template>
</xsl:stylesheet>
</gel:parse>

<x:parse var="xog_xsl"><gel:include select="$src_xsl" /></x:parse>
<x:parse var="emailMsg"><gel:include select="$emailMsg" /></x:parse>

<gel:parse var="src_corrected">
<x:transform xml="${emailMsg}" xslt="${xog_xsl}" />
</gel:parse>

<gel:set select="$src_corrected" var="xog_output" asString="true" />
<gel:log level="INFO" category="XML_DUMP">${xog_output}</gel:log>

</gel:script>


- Output to the gel process instance messages log:

[XML_DUMP]<?xml version="1.0" encoding="UTF-8"?> <img src="http://test:123/niku/something/something"/>  

     

Additional Information:

Reference TEC1398937  : PPM 14.2 Generic Patch available to resolve reported issues

Reference CA PPM Resolved Defects Index for CA PPM 14.3

Reference TEC1829325 : Backslash is deleted when saving a gel script that reads a pipe delimited file (CLRT-78367)