Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Element attr without quotes #4

Closed
bieleckim opened this issue Nov 25, 2014 · 1 comment
Closed

Element attr without quotes #4

bieleckim opened this issue Nov 25, 2014 · 1 comment

Comments

@bieleckim
Copy link

<a href=/index.php/example>Example</a>

$e->query('a')->attr('href') return "e" (last char in href i think), should return "/index.php/example".

@cyberbeat
Copy link

This is a bug in gan_parser_html.php, this is a fix:

function parse_attributes() {
    $this->status['attributes'] = array();

    while ($this->next_no_whitespace() === self::TOK_IDENTIFIER) {
        $attr = $this->getTokenString();
        if (($attr === '?') || ($attr === '%')) {
            //Probably closing tags
            break;
        }

        if ($this->next_no_whitespace() === self::TOK_EQUALS) {
            $this->token_start = $this->pos;
            if ($this->next_no_whitespace() === self::TOK_STRING) {
                $val = $this->getTokenString(1, -1);
            } else {
                if (!isset($stop)) {
                    $stop = $this->whitespace;
                    $stop['<'] = true;
                    $stop['>'] = true;
                }
                while ((++$this->pos < $this->size) && (!isset($stop[$this->doc[$this->pos]]))) {}
                --$this->pos;
                $val = $this->getTokenString();
                if (trim($val) === '') {
                    $this->addError('Invalid attribute value');
                    return false;
                }
            }
        } else {
            $val = $attr;
            $this->pos = (($this->token_start) ? $this->token_start : $this->pos) - 1;
        }

        $this->status['attributes'][$attr] = $val;
    }

    return true;
}

edit (21.12.2014): previous fix had an error, now it works

@tburry tburry closed this as completed in 11881e6 Jan 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants