As designed Code block freaks out when sharing specific snippet

Isn't it a desired behavior that the [/CODE] tag makes the code-block end? I don't see any unexpected behavior here.

You could change the PHP in order to make the markup work with XF as intended:

Code:
    /**
     * Handles inline code and code tags.
     *
     * @param string $text
     * @param Tag $tag
     *
     * @return mixed
     */
    public function handleTagCode($text, Tag $tag)
    {
        if (\preg_match('#\r\n|\r|\n#', $text))
        {
            return '[CODE]' . $text . '[' . '/CODE]';
        }

        return '[ICODE]' . $text . '[/ICODE]';
    }
 
This is generally as expected and it's pretty much the exact problem you see in JS trying to use a </script> tag within it.

You can't really get into trying to handle nesting because then a different problem happens: the presence of a [code] open within the content then means that the tag doesn't get closed when expected (as the close tag would be matched with the inner tag).

So there aren't any changes to be made here.
 
Back
Top Bottom