Unable to paste from spreadsheet

Better workaround:

Diff:
--- a/src/XF/Html/Renderer/BbCode.php
+++ b/src/XF/Html/Renderer/BbCode.php
@@ -491,6 +491,12 @@ class BbCode
      */
     public function renderCss(Tag $tag, $stringOutput)
     {
+        // Workaround: https://xenforo.com/community/threads/unable-to-paste-from-spreadsheet.223298/
+        if (preg_match('/^\[(th|td)/i', $stringOutput))
+        {
+            return $stringOutput;
+        }
+
         $css = $tag->attribute('style');
         if ($css)
         {
 
It looks like this bug still exists, and it’s surprising how quiet this thread has been. Is it being discussed somewhere else?

Thanks for the workaround, @Steffen. Although it removes all cell customizations, it does the job. Better to lose customization instead of garbage entries.
Perhaps the following could be an alternative to using preg_match? (Also, I think only td is affected, but it should be fine to include tr as well.)

PHP:
if (in_array($tag->tagName(), ['td', 'tr']))
 
Moved one of my sites to XF 2.3 and already have users complaining about this. The nature of the site is such that there are a LOT of copy/paste from spreadsheets so this is a very unexpected, and unwelcomed regression from XF 2.2.

Here's another instance to look into:

When I copy the table into the editor, it looks fine:

Screenshot 2025-02-13 092119.webp

However, when I hit preview, it changes the bottom line...

Screenshot 2025-02-13 092144.webp

When I submitted the post, it (obviously) took the preview version of the table, which is 💩. You can see the result, after the thread was posted, here: https://xenforo.com/community/threads/table-copy-paste-test.229188/
 
This previously worked before upgrading to 2.3
We have the same problem too, in 2.3 and 2.4.
Give a try here instead:

Valori nutrizionali - Composizione Chimica

Parte edibile100%-
Acqua42 g-
Carboidrati disponibili0-
Carboidrati complessi0-
Zuccheri solubili0-
Proteine35,60 g-
Grassi (Lipidi)14,20 g-
[TR]
[td]Composizione chimica[/td][td]valore per 100g[/td][td]RDA (%)[/td]
[/TR]
 
I'm also facing this issue... I have pasted in from Excel and Sheets - errors as shown throughout this test thread.

But removing formatting get's closer but still not usable.
 
It looks like this bug still exists, and it’s surprising how quiet this thread has been. Is it being discussed somewhere else?

Thanks for the workaround, @Steffen. Although it removes all cell customizations, it does the job. Better to lose customization instead of garbage entries.
Perhaps the following could be an alternative to using preg_match? (Also, I think only td is affected, but it should be fine to include tr as well.)

PHP:
if (in_array($tag->tagName(), ['td', 'tr']))
We had to fix this on our own site. The 'th' tag is also affected and should be added to this list.
 
Back
Top Bottom