Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-158827

Image Field attributes having character / receives character \ before them



      Steps to reproduce

      • Go to Content & Data > Web Content
      • Click on Structures tab
      • Add a new Structure with a Image field
      • Click on Advanced tab and copy the Field Reference
      • Save
      • Click on Web Content tab
      • Add a Web Content using the created Structure. Make sure to input Hyperloop is intented to reach 1200 km/h speed, without difficulty in the image description field.
      • Go to Design > Templates
      • Click on Widget Templates
      • Add an Asset Publisher Template with the following code:
      <#if entries?has_content>
      	<#list entries as entry>
      		<#assign docXml =  saxReaderUtil.read(entry.getAssetRenderer().getArticle().getContentByLocale(locale)) >		<#assign ArtImage = docXml.valueOf("//dynamic-element[@name='fieldReferenceOfImageField']/dynamic-content/text()") />		<#if ArtImage?has_content>
      				<#assign ArtImageDiv = ArtImage?eval />

      Note: replace the name fieldReferenceOfImageField by the Field Reference copied by you previously

      • Go to Site Builder > Pages and create a new page of type Widget Page
      • Go to the created Widget Page and drag and drop an Asset Publisher
      • Go to the Asset Publisher Configuration and choose Dynamic in the Asset Selection section
      • Click on the Display Settings
      • Select the created Template as the Display Template
      • Save and check how the Asset Publisher displays the Web Content


      Actual result

      The Web Content isn't displayed and the following error is shown instead:

      Failed to "?eval" string with this error:
      Syntax error in ?eval-ed string in line 1, column 49:
      Lexical error: encountered "/" (47), after "\"Hyperloop is intented to reach 1200 km\\".
      The failing expression:
      ==> ArtImage?eval  [in template "20097#20123#41371" at line 8, column 56]
      FTL stack trace ("~" means nesting-related):
      	- Failed at: #assign ArtImageDiv = ArtImage?eval  [in template "20097#20123#41371" at line 8, column 33]
      				1<#if entries?has_content> 
      				2	<#list entries as entry> 
      				3		<#assign docXml =  saxReaderUtil.read(entry.getAssetRenderer().getArticle().getContentByLocale(locale)) > 
      				5		<#assign ArtImage = docXml.valueOf("//dynamic-element[@name='Image21837887']/dynamic-content/text()") /> 
      				7		<#if ArtImage?has_content> 
      				8				<#assign ArtImageDiv = ArtImage?eval /> 
      				9		</#if> 
      				10	</#list> 


      New error (09th August 2022):

      An error occurred while processing the template.
      The following has evaluated to null or missing:
      ==> entry.getAssetRenderer().getArticle  [in template "20097#20123#43474" at line 3, column 55]
      Tip: It's the step after the last dot that caused this error, not those before it.
      Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
      FTL stack trace ("~" means nesting-related):
      	- Failed at: #assign docXml = saxReaderUtil.read(e...  [in template "20097#20123#43474" at line 3, column 17]
      1<#if entries?has_content> 
      2	<#list entries as entry> 
      3		<#assign docXml =  saxReaderUtil.read(entry.getAssetRenderer().getArticle().getContentByLocale(locale)) >		<#assign ArtImage = docXml.valueOf("//dynamic-element[@name='image']/dynamic-content/text()") />		<#if ArtImage?has_content> 
      4				<#assign ArtImageDiv = ArtImage?eval /> 
      5		</#if> 
      6	</#list> 


      Expected result

      The Web Content should be displayed without errors




            rafaella.jordao Rafaella Jordao
            renato.rego Renato Rêgo
            Felipe Lins Felipe Lins
            Carolina Barbosa Carolina Barbosa
            0 Vote for this issue
            1 Start watching this issue


              36 weeks, 4 days ago


                Version Package
       CE GA42
       CE GA44
       CE GA45