omsf-eco-infra / ticgithub

Tools to use a GitHub repository as a support ticket system
MIT License
0 stars 0 forks source link

Escape @ when appropriate #42

Closed dwhswenson closed 1 year ago

dwhswenson commented 1 year ago

If someone uses @ to refer to a person in an email (like @Joey), this will turn into a GitHub @-mention. It is unlikely that the person's first name is actually their GitHub handle, and it is reasonably likely that you're pinging someone who isn't relevant.

For private repos, I believe it is still the case that the person will not have access to the thread (or even receive the ping), but we should still filter for @-mentions.

I'd like to keep the automatic creation of email links. It'll take some experimentation, but I think there's a regex of the form:

[prefix symbols]@[allowed first chars for GitHub usernames]

where we can replace the @ by @<!-- -->, using an empty comment as a blocker. This prevents GitHub from generating @-mentions.

dwhswenson commented 1 year ago

@dwhswenson /@dwhswenson a@dwhswenson -@dwhswenson ~@dwhswenson .@dwhswenson .@dwhswenson.net .@dwhswenson.net (with empty comment to hide) ?@dwhswenson !@dwhswenson @@dwhswenson 1@dwhswenson (@dwhswenson foo@dwhswenson blah!@dwhswenson @dwhswenson

It looks to me like any prefix that isn't alphanumeric will trigger the GitHub mention. So the prefix is ^[A-Za-z0-9]. GitHub usernames need to start with an alphanumeric. For now, we're fine with just taking the first character after the @. This will disable emails in, e.g., the subtle email address .@dwhswenson.net (TBH, not sure if that's an allowed email).