GM_safeHTMLParser kills href attributes that don't start with URL scheme #17

Closed
ghost opened this Issue Sep 16, 2012 · 1 comment

Comments

Projects
None yet
1 participant
@ghost

ghost commented Sep 16, 2012

Code:

var examples = [
    '<html><body><a href="http://example.com/foo.bar">Click</a></body></html>',
    '<html><body><a href="/foo.bar">Click</a></body></html>',
    '<html><body><a href="foo.bar">Click</a></body></html>'
];

examples.forEach(function(html) {
    var a = GM_safeHTMLParser(html).querySelector('a');
    GM_log(a.hasAttribute('href'));
});

Output:

true
false
false

I'm currently getting by with replacing "href" with "data-href" beforehand. Would be cleaner without it.

@supahgreg supahgreg closed this in b956bae Sep 16, 2012

@supahgreg

This comment has been minimized.

Show comment
Hide comment
@supahgreg

supahgreg Sep 16, 2012

Contributor

I think the best we'll be able to do is allow you to specify the base URL to resolve any partial URLs. What you're seeing seems to be a limitation of the underlying code we're using to generate the fragment (link).

Contributor

supahgreg commented Sep 16, 2012

I think the best we'll be able to do is allow you to specify the base URL to resolve any partial URLs. What you're seeing seems to be a limitation of the underlying code we're using to generate the fragment (link).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment