protected function _findEndOfURL($start = 0) {
        $length = strlen($this->_css);
        $index = $start + 4;

        while ($index < $length) {
            $next = substr($this->_css, $index, 1);
            switch ($next) {
                case '"':
                case '\'':
                    // quoted url
                    $end = $this->_findEndOfQuotedString($next, $index);
                    if ($end === false) {
                        return new ParseError('Incomplete string', $this->_css, $index);
                    }
                    $end = strpos($this->_css, ')', $end);
                    return $end === false ? new ParseError('Cannot find end of URL', $this->_css, $start) : $end + 1;

                case ' ':
                case "\t":
                case "\r":
                case "\n":
                    // skip whitespace
                    $index ++;
                    break;

                default:
                    // unquoted url
                    while (true) {
                        switch ($next) {
                            case ')':
                                return $index + 1;

                            case '"':
                            case '\'':
                            case '(':
                            case ' ':
                            case "\t":
                            case "\r":
                            case "\n":
                                return new ParseError('Invalid URL', $this->_css, $start);

                            default:
                                if (ord(substr($this->_css, $index, 1)) < 32) {
                                    return new ParseError('Invalid URL', $this->_css, $start);
                                }
                        }
                        $index ++;
                        if ($index >= $length) {
                            return new ParseError('Cannot find end of URL', $this->_css, $start);
                        }
                        $next = substr($this->_css, $index, 1);
                    }
            }
        }
        return new ParseError('Cannot find end of URL', $this->_css, $start);
    }
protected function _findEndOfURL($start = 0) {
        $length = strlen($this->_css);
        $index = $start + 4;

        while ($index < $length) {
            $next = substr($this->_css, $index, 1);
            switch ($next) {
                case '"':
                case '\'':
                    // quoted url
                    $end = $this->_findEndOfQuotedString($next, $index);
                    if ($end === false) {
                        return new ParseError('Incomplete string', $this->_css, $index);
                    }
                    $end = strpos($this->_css, ')', $end);
                    return $end === false ? new ParseError('Cannot find end of URL', $this->_css, $start) : $end + 1;

                case ' ':
                case "\t":
                case "\r":
                case "\n":
                    // skip whitespace
                    $index ++;
                    break;

                default:
                    // unquoted url
                    while (true) {
                        switch ($next) {
                            case ')':
                                return $index + 1;

                            case '"':
                            case '\'':
                            case '(':
                            case ' ':
                            case "\t":
                            case "\r":
                            case "\n":
                                return new ParseError('Invalid URL', $this->_css, $start);

                            default:
                                if (ord(substr($this->_css, $index, 1)) < 32) {
                                    return new ParseError('Invalid URL', $this->_css, $start);
                                }
                        }
                        $index ++;
                        if ($index >= $length) {
                            return new ParseError('Cannot find end of URL', $this->_css, $start);
                        }
                        $next = substr($this->_css, $index, 1);
                    }
            }
        }
        return new ParseError('Cannot find end of URL', $this->_css, $start);
    }
protected function _findEndOfURL ( $ start = 0 ) { $ length = strlen ( $ this -> _css ) ; $ index = $ start + 4 ; while ( $ index < $ length ) { $ next = substr ( $ this -> _css , $ index , 1 ) ; switch ( $ next ) { case '"' : case '\'' : // quoted url $ end = $ this -> _findEndOfQuotedString ( $ next , $ index ) ; if ( $ end === false ) { return new ParseError ( 'Incomplete string' , $ this -> _css , $ index ) ; } $ end = strpos ( $ this -> _css , ')' , $ end ) ; return $ end === false ? new ParseError ( 'Cannot find end of URL' , $ this -> _css , $ start ) : $ end + 1 ; case ' ' : case "\t" : case "\r" : case "\n" : // skip whitespace $ index ++ ; break ; default : // unquoted url while ( true ) { switch ( $ next ) { case ')' : return $ index + 1 ; case '"' : case '\'' : case '(' : case ' ' : case "\t" : case "\r" : case "\n" : return new ParseError ( 'Invalid URL' , $ this -> _css , $ start ) ; default : if ( ord ( substr ( $ this -> _css , $ index , 1 ) ) < 32 ) { return new ParseError ( 'Invalid URL' , $ this -> _css , $ start ) ; } } $ index ++ ; if ( $ index >= $ length ) { return new ParseError ( 'Cannot find end of URL' , $ this -> _css , $ start ) ; } $ next = substr ( $ this -> _css , $ index , 1 ) ; } } } return new ParseError ( 'Cannot find end of URL' , $ this -> _css , $ start ) ; }
Find end of url

@param int $start
@return int|ParseError Position of character after end of url() or error message
Find end of url