SBBCodeParser icon indicating copy to clipboard operation
SBBCodeParser copied to clipboard

"=" in a URL

Open diegargon opened this issue 12 years ago • 4 comments

If the [url='...'] have a '=' like "index.php?view=1"

$atribbs seems empty and get filled by

if(empty($attribs['default'])) $attribs['default'] = $content;

i think...

Result-> bad url

diegargon avatar Nov 26 '13 20:11 diegargon

I'm also experiencing this issue.

doctorjbeam avatar Dec 02 '13 10:12 doctorjbeam

In Document.php

line 878 (i think i edit and not check

change

if($attribs[0] == '=' && strrpos($attribs, '=') === 0)

if($attribs[0] == '=')

I don't now if this break something (possibility) , its a fast patch without try understand why that check, but now works for me if appears any error with url tag i will check again.

diegargon avatar Dec 03 '13 19:12 diegargon

that check its for bbcodes with two arguments, if any bbcode have two arguements will get a error. i don't known which bbcode have two arguements

diegargon avatar Dec 03 '13 20:12 diegargon

The final solution it's working 100% but it needs some optimizations ^_^

In the classes/Node/Container/Document.php change the parse function header to be like that

public function parse($str)
    {
        //$str      = preg_replace('/[\r\n|\r]/', "\n", $str);
        //This is the added code
        $bbstr = $str;
        $result = "";
        while (strpos($bbstr, "[url=") !== false) {
            $pos = strpos($bbstr, "[url=")+5;
            $result .= substr($bbstr,0,$pos);
            $bbstr = substr($bbstr,$pos,strlen($bbstr));
            $pos = strpos($bbstr, "]")-1;
            $link = substr($bbstr,0,$pos+1);if($pos<0)$link="#";
            $link = str_replace('=',"IXI_SBBCODEPARSER_URL_PROBLEM_IS_SOLVED",$link);
            $bbstr = substr($bbstr,$pos+1,strlen($bbstr));
            $result .= $link;
        }
        $result .= $bbstr;
        $str = $result;//The added code ends here


        $len      = strlen($str);
        $tag_open = false;
        $tag_text = '';
        $tag      = '';
...

And in the classes/Node/Container.php change the function get_html() to oldget_html() then add this function :

/**
    *
    * @return string
    */
    public function get_html($nl2br=true){
        return str_replace("IXI_SBBCODEPARSER_URL_PROBLEM_IS_SOLVED",'=',$this->oldget_html($nl2br));
    }

and now every thing will run without any problem

Suggestion : I think that we can use @diegargon solution if we will be able to specify the tag ([URL]) in the IF statement

Khalilbz avatar Aug 17 '16 21:08 Khalilbz