Skip to content

Loading…

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

Closed
ghost opened this Issue · 1 comment

1 participant

@ghost

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 added a commit that closed this issue
@supahgreg supahgreg Add the 'aBaseURL' argument to GM_safeHTMLParser, which allows script…
… authors to specify a base URL to be used when resolving partials. Closes #17

(cherry picked from commit ee9ff4801c50abedfd1ad61a6a6243884261e363)
b956bae
@supahgreg supahgreg closed this in b956bae
@supahgreg

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
Something went wrong with that request. Please try again.