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
Invalid metadata in "New script template" prevents creation of new scripts #2336
Comments
See also (meta is null) - after script editing: // ==UserScript==
// ==/UserScript==
var something; A little strange code (AFAIK): Ad https://github.com/greasemonkey/greasemonkey/blob/3.5/modules/parseScript.js#L35: Option 1: From: if (!meta && aNoMetaOk) {
setDefaults(script);
return script;
}
var resourceNames = {};
for (var i = 0, metaLine = ''; metaLine = meta[i]; i++) { To: var resourceNames = {};
for (var i = 0, count = meta ? meta.length : 0; i < count; i++) {
var metaLine = meta[i]; or if (!meta) {
if (aNoMetaOk) {
setDefaults(script);
return script;
} else {
// log error... (script.parseErrors.push...)
}
}
var resourceNames = {};
for (var i = 0, count = meta ? meta.length : 0; i < count; i++) {
var metaLine = meta[i]; Option 2: ? |
The testing branch (Option 1b): |
Ok, I opened th GM Options dialog, typed "foo" into the template box, hit OK. Then Monkey menu>new user script. Type any name and hit OK. Get an error in the console with traceback:
The line parseScript.js:41 is trying to loop over In fact, only one code path, All that logic is confused and should be cleaned up, which may implicitly fix this issue. |
This should be fixed in 3.7beta2: https://addons.mozilla.org/firefox/downloads/file/388504/greasemonkey-3.7beta2-fx.xpi?src=devhub I'd appreciate confirmation either way. |
Is there a pref or something to let me install that in Dev or Release, or does it have to be Nightly? AMO is in the list of sites allowed to install extensions but both the aforementioned versions of Firefox just inform me they're not letting AMO ask to install it, and don't give the option to allow. |
Extensions hosted on AMO should be installable for any Firefox. Perhaps use the versions page? https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/versions/ |
Thanks, I guess it was just the direct link it didn't like. Can confirm this issue is fixed. |
I think Firefox controls "can install an XPI" by the site that the link is on, rather than the site that the XPI is served from. |
I ran into this issue because mysteriously, months after I last touched this setting, the newlines in my custom template were lost/replaced.
To reproduce, put some random junk in "New script template" in Greasemonkey's options panel, go to add a new script, and click the Okay button to add it. Observe the null reference exception in the console and the lack of a new script being added.
The variable
meta
inparseScript.js::parse()
coming fromextractMeta.js::extractMeta()
is null after attempting to extract invalid metadata (even thoughextractMeta()
is clearly supposed to return an empty string if the regex doesn't match). There are a couple of "if not meta" lines inparse()
that look like they should fall back on defaults for a null/empty metadata string, but apparentlyaNoMetaOk
is true so it keeps going until the null reference.I would have submitted a PR but I'm not sure what exactly
aNoMetaOk
's purpose in life is and what changes are okay there.The text was updated successfully, but these errors were encountered: