summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorunarist <m.unarist@gmail.com>2018-04-09 01:10:04 +0900
committerunarist <m.unarist@gmail.com>2018-04-09 01:52:41 +0900
commit3c4235067f2ff1f8057080482559a8015f0492c6 (patch)
tree8ed49d9d10af0e7f9f70b27cb7dfb6f0173b0d4a /src
parentMerge pull request #1420 from unarist/fix/banner-selection (diff)
downloadmisskey-3c4235067f2ff1f8057080482559a8015f0492c6.tar.gz
misskey-3c4235067f2ff1f8057080482559a8015f0492c6.tar.bz2
misskey-3c4235067f2ff1f8057080482559a8015f0492c6.zip
Fix username/mention regexes
* Allow underscore instead of hypen * Fix domain part handling * Add tests for remote mention
Diffstat (limited to 'src')
-rw-r--r--src/client/app/common/views/components/signup.vue2
-rw-r--r--src/client/app/dev/views/new-app.vue2
-rw-r--r--src/models/app.ts2
-rw-r--r--src/models/user.ts2
-rw-r--r--src/text/parse/elements/mention.ts2
5 files changed, 5 insertions, 5 deletions
diff --git a/src/client/app/common/views/components/signup.vue b/src/client/app/common/views/components/signup.vue
index e77d849ade..8d0b16cabd 100644
--- a/src/client/app/common/views/components/signup.vue
+++ b/src/client/app/common/views/components/signup.vue
@@ -76,7 +76,7 @@ export default Vue.extend({
}
const err =
- !this.username.match(/^[a-zA-Z0-9\-]+$/) ? 'invalid-format' :
+ !this.username.match(/^[a-zA-Z0-9_]+$/) ? 'invalid-format' :
this.username.length < 3 ? 'min-range' :
this.username.length > 20 ? 'max-range' :
null;
diff --git a/src/client/app/dev/views/new-app.vue b/src/client/app/dev/views/new-app.vue
index c9d5971395..2317f24d48 100644
--- a/src/client/app/dev/views/new-app.vue
+++ b/src/client/app/dev/views/new-app.vue
@@ -65,7 +65,7 @@ export default Vue.extend({
}
const err =
- !this.nid.match(/^[a-zA-Z0-9\-]+$/) ? 'invalid-format' :
+ !this.nid.match(/^[a-zA-Z0-9_]+$/) ? 'invalid-format' :
this.nid.length < 3 ? 'min-range' :
this.nid.length > 30 ? 'max-range' :
null;
diff --git a/src/models/app.ts b/src/models/app.ts
index 83162a6b99..703f4ef8f5 100644
--- a/src/models/app.ts
+++ b/src/models/app.ts
@@ -24,7 +24,7 @@ export type IApp = {
};
export function isValidNameId(nameId: string): boolean {
- return typeof nameId == 'string' && /^[a-zA-Z0-9\-]{3,30}$/.test(nameId);
+ return typeof nameId == 'string' && /^[a-zA-Z0-9_]{3,30}$/.test(nameId);
}
/**
diff --git a/src/models/user.ts b/src/models/user.ts
index ea59730e4d..36c63a56da 100644
--- a/src/models/user.ts
+++ b/src/models/user.ts
@@ -89,7 +89,7 @@ export const isRemoteUser = (user: any): user is IRemoteUser =>
//#region Validators
export function validateUsername(username: string): boolean {
- return typeof username == 'string' && /^[a-zA-Z0-9\-]{3,20}$/.test(username);
+ return typeof username == 'string' && /^[a-zA-Z0-9_]{3,20}$/.test(username);
}
export function validatePassword(password: string): boolean {
diff --git a/src/text/parse/elements/mention.ts b/src/text/parse/elements/mention.ts
index 4f2997b39f..2ad2788300 100644
--- a/src/text/parse/elements/mention.ts
+++ b/src/text/parse/elements/mention.ts
@@ -4,7 +4,7 @@
import parseAcct from '../../../acct/parse';
module.exports = text => {
- const match = text.match(/^(?:@[a-zA-Z0-9\-]+){1,2}/);
+ const match = text.match(/^@[a-z0-9_]+(?:@[a-z0-9\.\-]+[a-z0-9])?/i);
if (!match) return null;
const mention = match[0];
const { username, host } = parseAcct(mention.substr(1));