Background to String Properties in EPiServer

When EPiServer 4 was released there was two built in property types to handle string content: PropertyString and PropertyLongString.

The two major differences between the two:

  1. PropertyString could only handle content up two 255 characters while PropertyLongString could handle any strings of any length.
  2. PropertyLongString had an html editor to handle the content for editors.

Later on during EPiServer CMS 4 development PropertyXhtmlString was introduced. This made it possible to parse the content that the editor produced to xhtml to ensure that it was possible to create pages that were xhtml 1.0 compatible.

It was up to each site to decide if to use PropertyXhtmlString or PropertyLongString for longer string content. Furthermore, since this is configured per page type property, it was even possible to use both PropertyLongString and PropertyXhtmlString properties for the same site.

With the introduction of permanent links (links in editor content that are not broken when objects, for instance files, are moved or renamed) there appeared another major difference between the longstring and xhtmlstring property since this was only supported for PropertyXhtmlString properties. When dynamic content was introduced to the EPiServer CMS core later in the CMS 5 development life cycle this was also supported only for PropertyXhtmlString properties.

Recommendations

Another thing you need to consider if you use a PropertyLongString with unparsed content is that the FriendlyUrl functionality, if turned on, will itself parse any content that is contained in the content (html) of a page to xhtml. This might cause unparsed content to differ on the actual page view compared to the data storage or editors view of the property.

EPiServer CMS introduces a changed behavior on how basic longstring content is presented on a page. In EPiServer CMS 5, a property of type PropertyLongString with all editor options (bold, fonts etc) turned off would result in a basic textarea as the editors input control. This content would then be written directly to a page template without any manipulation.

In EPiServer CMS , the default behavior is to always use the default string manipulation. r /> This includes conversion of the characters “<>&” to their respective html entities: “<”, “>” and “&”.

It also ensures that any html tags that are not specified in the configuration settings “UISafeHtmlTags” are replaced with the text version of the tags.

For instance, <script> would be replaced with &lt;script&gt; to ensure that script from user input will not be executed on the page. If this behavior is not what you want on your property this would be solved by overriding the ToWebString method on your custom property. <script> would be replaced with <script> to ensure that script from user input will not be executed on the page.

If this behavior is not what you want on your property this would be solved by overriding the ToWebString method on your custom property.