U4-6785 - Texbox multiple linebreaks change from \n to \r\n after republish

Created by Bart ten Velde 02 Jul 2015, 15:24:02 Updated by Chriztian Steinmeier 06 Jul 2015, 17:09:24

Hi, using multiple lines in a "textbox multiple" property results in linebreak as '\n' after save & publish and changes to '\r\n' after a right click on 'content' and choose 'Republish entire site'.

More details in forum post at https://our.umbraco.org/forum/developers/api-questions/67069-texbox-multiple-linebreaks-change-from-n-to-rn-after-republish

Comments

Stephan 06 Jul 2015, 12:35:59

Notes:

  • value is saved in db (cmsPropertyData) with LF (\n) only
  • value is saved in db (cmsContentXml) with CRLF (\r\n)

So when value is read back from database (republish entire site) we get the CRLF.

When we serialize, ContentXmlEntity.Xml is an XElement and the value has LF. Then we do .ToString(SaveOptions.None) and the value has CRLF. As per MSDN, None means "Format (indent) the XML while serializing." and that seem to include the CDATA content, whereas DisableFormatting would "Preserve all insignificant white space while serializing.".

If we want to respect whatever white spaces are in the content of a property, then we should use DisableFormatting.


Stephan 06 Jul 2015, 13:12:46

Notes: DisableFormatting does not change anything, if XElement value contains LF then ToString turns it into CRLF. Need another solution...


Stephan 06 Jul 2015, 13:35:48

Looks like there is no way to get ToString() to produce the string we want, had to resort to an XmlWriter with specific settings, so the CR and LF in the original data string are preserved. So now what we get in the cache after a full reload is identical to what was in the cache originally.

This is 39a9d68f4304c1101b491e63f997502d7d8b356d


Chriztian Steinmeier 06 Jul 2015, 17:09:24

Cool - nice work!


Priority: Normal

Type: Bug

State: Fixed

Assignee: Stephan

Difficulty: Normal

Category: Architecture

Backwards Compatible: True

Fix Submitted:

Affected versions: 7.1.8, 7.2.6

Due in version: 7.3.0

Sprint:

Story Points:

Cycle: