Display name expression for some Norwegian symbols


#1

Enonic version: 7.0.2
OS: Linux

We have a display name expression and it seems to break when we get some specific symbols in input.
This is our displayName script:
<display-name-expression>${NEWS_TITLE}</display-name-expression>
Here is the log:

Cannot evaluate script ["use strict";var NEWS_TITLE = 'Ugrasbekjemping viktig ved nyetablering av eng '; var NEWS_TYPE = 'REGULAR'; var NEWS_IMAGE_CAPTION = '<p>Foto: </p>
'; var NEWS_BYLINE_STRING = ''; var NEWS_INGRESS_SHORT = 'har sett på hvordan man kan få høy grovfôravling med minst mulig bruk av plantevernmidler. Det viktigste tiltaket bonden kan gjøre er å bekjempe ugras ved etablering av ny eng.'; var NEWS_INGRESS = 'har sett på hvordan man kan få høy grovfôravling med minst mulig bruk av plantevernmidler. Det viktigste tiltaket bonden kan gjøre er å bekjempe ugras ved etablering av ny eng.'; `${NEWS_TITLE}`.replace(/\s+/g, ' ')]. SyntaxError: Invalid or unexpected token
    at DisplayNameResolver.safeEval (bundle.js:1)
    at DisplayNameResolver.execute (bundle.js:1)
    at HTMLDivElement.<anonymous> (bundle.js:1)
DisplayNameResolver.safeEval @ bundle.js:1
DisplayNameResolver.execute @ bundle.js:1
(anonymous) @ bundle.js:1

#2

Which version of Content Studio are you on? This was fixed in the latest 2.0.3. See also Display name empty when using <display-name-expression> in a content-type that contains a HtmlArea input


#3

Hi!
We are using the latest Content Studio 2.0.3.


#4

Strange, I tested it with your text and didn’t get any errors… Can you share you content type schema?


#5

Hi!
Here is the content type:

<?xml version="1.0" encoding="UTF-8"?>
<content-type>
  <display-name>News</display-name>
  <display-name-expression>${NEWS_TITLE}</display-name-expression>
  <super-type>base:structured</super-type>
  <form>
    <input name="RELATED_LOCALE" type="ContentSelector">
      <label>News page in other languages</label>
      <occurrences minimum="0" maximum="1"/>
      <config>
        <relationshipType>system:reference</relationshipType>
        <allowPath>*</allowPath>
        <allowContentType>news</allowContentType>
      </config>
    </input>
    <input type="TextArea" name="NEWS_TITLE">
      <label>Title</label>
      <occurrences minimum="1" maximum="1"/>
    </input>
    <input type="ComboBox" name="NEWS_TYPE">
      <label>News Type</label>
      <occurrences minimum="1" maximum="1"/>
      <config>
        <option value="FEATURED">Featured</option>
        <option value="REGULAR">Regular</option>
        <option value="MINOR">Minor</option>
      </config>
    </input>
    <input type="ImageSelector" name="NEWS_IMAGE">
      <label>Main image</label>
      <occurrences minimum="1" maximum="1"/>
    </input>
    <input type="HTMLArea" name="NEWS_IMAGE_CAPTION">
      <label>Image caption</label>
      <occurrences minimum="0" maximum="1"/>
    </input>
    <input name="NEWS_BYLINE" type="ContentSelector">
      <label>News byline content selector</label>
      <occurrences minimum="0" maximum="1"/>
      <config>
        <relationshipType>system:reference</relationshipType>
        <allowPath>*</allowPath>
        <allowContentType>employee</allowContentType>
      </config>
    </input>
    <input name="NEWS_BYLINE_STRING" type="TextLine">
      <label>News byline string</label>
    </input>
    <input type="TextArea" name="NEWS_INGRESS_SHORT">
      <label>Forsideingress</label>
      <occurrences minimum="0" maximum="1"/>
    </input>
    <input type="TextArea" name="NEWS_INGRESS">
      <label>Ingress</label>
      <occurrences minimum="1" maximum="1"/>
    </input>
    <input name="NEWS_CONTACT" type="ContentSelector">
      <label>Contact</label>
      <occurrences minimum="0" maximum="0"/>
      <config>
        <relationshipType>system:reference</relationshipType>
        <allowPath>*</allowPath>
        <allowContentType>employee</allowContentType>
      </config>
    </input>
    <input name="RELATED_PUBLICATIONS" type="ContentSelector">
      <label>Related publications</label>
      <occurrences minimum="0" maximum="0"/>
      <config>
        <relationshipType>system:reference</relationshipType>
        <allowPath>*</allowPath>
        <allowContentType>publication</allowContentType>
      </config>
    </input>
    <input name="RELATED_PROJECTS" type="ContentSelector">
      <label>Related projects</label>
      <occurrences minimum="0" maximum="0"/>
      <config>
        <relationshipType>system:reference</relationshipType>
        <allowPath>*</allowPath>
        <allowContentType>project</allowContentType>
      </config>
    </input>
    <input name="RELATED_NEWS" type="ContentSelector">
      <label>Related news</label>
      <occurrences minimum="0" maximum="0"/>
      <config>
        <relationshipType>system:reference</relationshipType>
        <allowPath>*</allowPath>
        <allowContentType>news</allowContentType>
      </config>
    </input>
    <mixin name="tags"/>
  </form>
</content-type>

#6

The problem here is that display name evaluator stumbles upon contents of the HTML Area. In version 2.1.0 of Content Studio we excluded HTML Area from display name expression. If it’s ok for you to upgrade to XP 7.1 / CS 2.1 then I suggest you do that. We could evaluate fixing it in CS 2.0.4 as well, but this will take some time.


#7

@ase Did you mean to write TextArea instead of HtmlArea? Because in the contenttype above, NEWS_TITLE is of type TextArea.

I think you could try a quick fix: Change NEWS_TITLE into a TextLine input. Mostly, any type of data in a TextArea is also compatible with TextLine. I think the only exception is certain types of whitespace, like tab or newline or carriage return characters. And even then, the limit might not be on the storage side, but rather that you cannot paste a string with tab/enter into a TextLine input.


#8

No, I meant HtmlArea. Display name expression parses all field values and - in this case - stumbles upon HtmlArea field which can have unpredictable values because of HTML inside. The walkaround is to clear the NEWS_IMAGE_CAPTION field. Or upgrade to Content Studio 2.1.0 where this problem is fixed.