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

Custom hotkeys don't work on users that partially match reserved names #26

Closed
monk-time opened this issue Sep 22, 2017 · 1 comment
Closed
Labels

Comments

@monk-time
Copy link

The script for adding custom hotkeys breaks if a repo owner partially matches any of Github's reserved names. For example, hotkeys don't work on git-for-windows/git because it has 'windows' in the owner's name.

This seems to be caused by JS testing a regex at all positions in a given string instead of only at the start (even without a global flag):

nonUser = new RegExp("(" + [
"400", "401", "402", "403", "404", "405", "406", "407", "408", "409",
"410", "411", "412", "413", "414", "415", "416", "417", "418", "419",
"420", "421", "422", "423", "424", "425", "426", "427", "428", "429",
"430", "431", "500", "501", "502", "503", "504", "505", "506", "507",
"508", "509", "510", "511", "about", "access", "account", "admin",
"anonymous", "api", "apps", "auth", "billing", "blog", "business",
"cache", "categories", "changelog", "codereview", "comments", "community",
"compare", "contact", "dashboard", "design", "developer", "docs",
"downloads", "editor", "edu", "enterprise", "events", "explore",
"features", "files", "gist", "gists", "graphs", "help", "home", "hosting",
"images", "info", "integrations", "issues", "jobs", "join", "languages",
"legal", "linux", "lists", "login", "logout", "mac", "maintenance",
"marketplace", "mine", "mirrors", "mobile", "navigation", "network",
"new", "news", "notifications", "oauth", "offer", "open-source",
"organizations", "orgs", "pages", "payments", "personal", "plans",
"plugins", "popular", "posts", "press", "pricing", "projects", "pulls",
"readme", "releases", "repositories", "search", "security", "services",
"sessions", "settings", "shop", "showcases", "signin", "signup", "site",
"ssh", "staff", "stars", "static", "status", "store", "stories",
"styleguide", "subscriptions", "support", "talks", "teams", "terms",
"tos", "tour", "translations", "trending", "updates", "username", "users",
"watching", "wiki", "windows", "works-with", "www1", "www2", "www3",
"www4", "www5", "www6", "www7", "www8", "www9"
].join("|") + ")");

// user name
if (nonUser.test(tmp[1] || "")) {
// invalid user! clear out the values
tmp = [];
}

I think this issue can be safely fixed by surrounding the regex with ^ and $.

P.S. Also it seems like the {me} scope is always undefined:

let tmp = $("meta[name='user-login']");
parts.m = tmp && tmp.getAttribute("content") || "";
parts.me = parts.me ? parts.root + "/" + parts.m : "";

@Mottie
Copy link
Owner

Mottie commented Sep 22, 2017

Hi @monk-time!

Thanks for letting me know about this problem. I'll have it fixed soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants