--- 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)
{
if (in_array($tag->tagName(), ['td', 'tr']))
We have the same problem too, in 2.3 and 2.4.This previously worked before upgrading to 2.3
Parte edibile | 100% | - |
Acqua | 42 g | - |
Carboidrati disponibili | 0 | - |
Carboidrati complessi | 0 | - |
Zuccheri solubili | 0 | - |
Proteine | 35,60 g | - |
Grassi (Lipidi) | 14,20 g | - |
Lucky you, I haven't yet had the chance to test 2.4We have the same problem too, in 2.3 and 2.4.
We had to fix this on our own site. The 'th' tag is also affected and should be added to this list.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']))
ParseError: syntax error, unexpected token "if" in src/XF/Html/Renderer/BbCode.php at line 495
Composer\Autoload\{closure}() in src/vendor/composer/ClassLoader.php at line 427
Composer\Autoload\ClassLoader->loadClass() in src/XF/ControllerPlugin/EditorPlugin.php at line 42
XF\ControllerPlugin\EditorPlugin->convertToBbCode() in src/XF/ControllerPlugin/EditorPlugin.php at line 21
XF\ControllerPlugin\EditorPlugin->fromInput() in src/XF/Pub/Controller/PostController.php at line 71
XF\Pub\Controller\PostController->setupPostEdit() in src/XF/Pub/Controller/PostController.php at line 154
XF\Pub\Controller\PostController->actionEdit() in src/XF/Mvc/Dispatcher.php at line 362
XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 264
XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 121
XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 63
XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2824
XF\App->run() in src/XF.php at line 806
XF::runApp() in index.php at line 23
/**
* Renders the CSS for a given tag.
*
* @param Tag $tag
* @param string $stringOutput
*
* @return string BB code output
*/
public function renderCss(Tag $tag, $stringOutput)
{
+ // Workaround: https://xenforo.com/community/threads/unable-to-paste-from-spreadsheet.223298/
+ if (preg_match('/^\[(TD|TR)/i', $stringOutput))
+ {
+ return $stringOutput;
+ }
$css = $tag->attribute('style');
if ($css)
{
foreach ($css AS $cssRule => $cssValue)
Steffen workaround did not worked for me, XF2.3
Code:ParseError: syntax error, unexpected token "if" in src/XF/Html/Renderer/BbCode.php at line 495 Composer\Autoload\{closure}() in src/vendor/composer/ClassLoader.php at line 427 Composer\Autoload\ClassLoader->loadClass() in src/XF/ControllerPlugin/EditorPlugin.php at line 42 XF\ControllerPlugin\EditorPlugin->convertToBbCode() in src/XF/ControllerPlugin/EditorPlugin.php at line 21 XF\ControllerPlugin\EditorPlugin->fromInput() in src/XF/Pub/Controller/PostController.php at line 71 XF\Pub\Controller\PostController->setupPostEdit() in src/XF/Pub/Controller/PostController.php at line 154 XF\Pub\Controller\PostController->actionEdit() in src/XF/Mvc/Dispatcher.php at line 362 XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 264 XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 121 XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 63 XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2824 XF\App->run() in src/XF.php at line 806 XF::runApp() in index.php at line 23
From my Bbcode.php:
Code:/** * Renders the CSS for a given tag. * * @param Tag $tag * @param string $stringOutput * * @return string BB code output */ public function renderCss(Tag $tag, $stringOutput) { + // Workaround: https://xenforo.com/community/threads/unable-to-paste-from-spreadsheet.223298/ + if (preg_match('/^\[(TD|TR)/i', $stringOutput)) + { + return $stringOutput; + } $css = $tag->attribute('style'); if ($css) { foreach ($css AS $cssRule => $cssValue)
/**
* Renders the CSS for a given tag.
*
* @param Tag $tag
* @param string $stringOutput
*
* @return string BB code output
*/
public function renderCss(Tag $tag, $stringOutput)
{
// Workaround: https://xenforo.com/community/threads/unable-to-paste-from-spreadsheet.223298/
if (preg_match('/^\[(TD|TR|TABLE)/i', $stringOutput))
{
return $stringOutput;
}
$css = $tag->attribute('style');
if ($css)
/**
* Renders the CSS for a given tag.
*
* @param Tag $tag
* @param string $stringOutput
*
* @return string BB code output
*/
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;
}
// End Workaround
$css = $tag->attribute('style');
if ($css)
{
UPDATE xf_post SET message = REPLACE(message, 'oldtext', 'newtext');
TABLE="class: x"] --> [TABLE]
[TD][B]Nr --> [TD width="25"][B]Nr
[TD][CENTER][B]LOC --> [TD width="25"][CENTER][B]LOC
[TD="width: 25"] --> [TD width="25"]
[TD="width: 120"] --> [TD width="120"]
[TD="width: 280"] --> [TD width="280"]
[TD="width: 20"] --> [TD width="20"]
TD="bgcolor:#2C75ee"] --> [TD]
[TD="bgcolor:#d31f1f"] --> [TD]
[TD="bgcolor:#00ff00"] --> [TD]
[TD="bgcolor:#ffff00"] --> [TD]
[TD="bgcolor:#ff0000"] --> [TD]
[TD="bgcolor:#ff8700"] --> [TD]
We use essential cookies to make this site work, and optional cookies to enhance your experience.