Fixed vB4 Import: CRLF vs. LF in signature and message text

Steffen

Well-known member
Affected version
2.0.2
vBulletin uses CRLF (carriage return + line feed) to encode a line break in signature and message text. XenForo uses just LF (line feed) because its InputFilterer class removes all carriage returns. When I "edit" a user signature or a post message without changing anything (i.e. I just save it immediately after opening the editor) then a user change log entry / post history entry is created. The diff does not highlight anything because only the encoding of line breaks has changed.

I think the vBulletin 4 importer should convert all CRLF instances in signatures / message texts / ... to LF.

Maybe all of the InputFilterer::$stringCleaning characters should be removed from imported texts?
 
Sorted, with a quick conversion in EntityEmulator::set()
Diff:
Index: src/XF/Import/Data/EntityEmulator.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/XF/Import/Data/EntityEmulator.php    (revision d4f8f0b2978cd833501dacdef39f5accb3eb9eef)
+++ src/XF/Import/Data/EntityEmulator.php    (date 1520956664000)
@@ -74,6 +74,12 @@
             throw new \InvalidArgumentException("Unknown column '$field'");
         }
 
+        // Convert CRLF to LF
+        if (is_string($value))
+        {
+            $value = str_replace("\r\n", "\n", $value);
+        }
+
         $vf = $this->valueFormatter;
         $originalValue = $value;
 
Back
Top Bottom