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
Relative @require uses wrong base URI in certain cases #1874
Comments
Take a look at the fix I selected and let me know what you think? |
Solving this centrally in So maybe we could just skip the cache completely if any argument is not Though that seems like a lot of complexity for a function that's only used 3 times so far - so I'm definitely fine with your fix. |
Oops. I intended to segregate the cache-key-args from the passed-to-wrapped-function args and did not. |
Ah, that makes much more sense! It still leaves the chance of accidentally passing a complex value through memoize, which then might return an uninteded result from the cache, though. But I guess that's just something we have to look out for when adding new memoized functions. |
Steps to reproduce:
@require
d script contains analert("Github")
.@require
directive as the previous script, but since it's installed from a different location, this time http://dump.ventero.de/greasemonkey/relative_require/c78475b522fe3a8a699e31312561075c2c20c742/require.js should be downloaded - which contains analert("Not Github")
.Expected result:
alert("Not Github")
is executed.Actual result:
alert("Github")
is executed.The reason for this is that a
nsIURI
object is passed to the memoizeduriFromUrl
. The memoization uses essentiallyuneval(arguments)
as cache key, which works fine as long as the arguments are primitives. For annsIURI
,uneval(uri)
however results in({})
. This then leads to an incorrect cached value being returned for the@require
d URL during installation of the second script.I can see 3 options on how to fix this issue:
uriFromUrl
. I don't think this is a good idea though, as this function is called quite often (for me, it's several hundred times per minute). Almost all calls are without a second argument or with a string though.uri.spec
instead (looks like there's only 4 such callers). But this causes unnecessary overhead, as the spec strings have to be converted back to a URI insideuriFromUrl
again.The text was updated successfully, but these errors were encountered: