diff --git a/client/components/common/page-selector.vue b/client/components/common/page-selector.vue index cf66c9cae0..de3aaade0f 100644 --- a/client/components/common/page-selector.vue +++ b/client/components/common/page-selector.vue @@ -103,8 +103,6 @@ import _ from 'lodash' import gql from 'graphql-tag' -const localeSegmentRegex = /^[A-Z]{2}(-[A-Z]{2})?$/i - /* global siteLangs, siteConfig */ export default { @@ -192,8 +190,6 @@ export default { const firstSection = _.head(this.currentPath.split('/')) if (firstSection.length <= 1) { return false - } else if (localeSegmentRegex.test(firstSection)) { - return false } else if ( _.some(['login', 'logout', 'register', 'verify', 'favicons', 'fonts', 'img', 'js', 'svg'], p => { return p === firstSection diff --git a/server/helpers/page.js b/server/helpers/page.js index 8bea0aa3b2..8d5e69260e 100644 --- a/server/helpers/page.js +++ b/server/helpers/page.js @@ -3,8 +3,9 @@ const _ = require('lodash') const crypto = require('crypto') const path = require('path') -const localeSegmentRegex = /^[A-Z]{2}(-[A-Z]{2})?$/i -const localeFolderRegex = /^([a-z]{2}(?:-[a-z]{2})?\/)?(.*)/i +// exclude Regex matches based on ISO 639-1 individual living languages +const localeSegmentRegex = /^(?!a[^abfmnsv])(?!b[^ameniosrg])(?!c[^ashevoy])(?!d[^aevz])(?!e[^lnue])(?!f[^ojiry])(?!g[^dalvu])(?!h[^taezioruy])(?!i[^gsidt])(?!j[^av])(?!k[^lnsakmiyoj])(?!l[^ointbug])(?!m[^khlirty])(?!n[^avrdglnby])(?!o[^cs])(?!p[^alt])(?!r[^monu])(?!s[^giklemndotrsuv])(?!t[^yateglhionskrw])(?!u[^gkr])(?!v[^ei])(?!w[^ao])(?!x[^h])(?!y[^o])(?!z[^u])[A-Z]{2}(-[A-Z]{2})?$/i +const localeFolderRegex = /^((?!a[^abfmnsv])(?!b[^ameniosrg])(?!c[^ashevoy])(?!d[^aevz])(?!e[^lnue])(?!f[^ojiry])(?!g[^dalvu])(?!h[^taezioruy])(?!i[^gsidt])(?!j[^av])(?!k[^lnsakmiyoj])(?!l[^ointbug])(?!m[^khlirty])(?!n[^avrdglnby])(?!o[^cs])(?!p[^alt])(?!r[^monu])(?!s[^giklemndotrsuv])(?!t[^yateglhionskrw])(?!u[^gkr])(?!v[^ei])(?!w[^ao])(?!x[^h])(?!y[^o])(?!z[^u])[a-z]{2}(?:-[a-z]{2})?\/)?(.*)/i // eslint-disable-next-line no-control-regex const unsafeCharsRegex = /[\x00-\x1f\x80-\x9f\\"|<>:*?]/