From 6a1ac35ca5b3634e0e0c7eb7e998c96f838f0a83 Mon Sep 17 00:00:00 2001 From: Brian Powell Jr Date: Sat, 16 Nov 2024 18:24:27 -0500 Subject: [PATCH 1/5] Updated new page modal to no longer disable page creation for page names 2 characters or less. Removed local regex check as the new page model already prepends the locale. --- client/components/common/page-selector.vue | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/client/components/common/page-selector.vue b/client/components/common/page-selector.vue index cf66c9cae0..b72c7f8ebe 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 { @@ -190,11 +188,7 @@ export default { return false } const firstSection = _.head(this.currentPath.split('/')) - if (firstSection.length <= 1) { - return false - } else if (localeSegmentRegex.test(firstSection)) { - return false - } else if ( + if ( _.some(['login', 'logout', 'register', 'verify', 'favicons', 'fonts', 'img', 'js', 'svg'], p => { return p === firstSection })) { From a850162f8f460eeffc2f1d595ce35e158d90356f Mon Sep 17 00:00:00 2001 From: Brian Powell Jr Date: Sat, 16 Nov 2024 19:21:31 -0500 Subject: [PATCH 2/5] revert path length check change in new page modal --- client/components/common/page-selector.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/components/common/page-selector.vue b/client/components/common/page-selector.vue index b72c7f8ebe..de3aaade0f 100644 --- a/client/components/common/page-selector.vue +++ b/client/components/common/page-selector.vue @@ -188,7 +188,9 @@ export default { return false } const firstSection = _.head(this.currentPath.split('/')) - if ( + if (firstSection.length <= 1) { + return false + } else if ( _.some(['login', 'logout', 'register', 'verify', 'favicons', 'fonts', 'img', 'js', 'svg'], p => { return p === firstSection })) { From 19275e346d38365f63597fbfde939929c43262a5 Mon Sep 17 00:00:00 2001 From: Brian Powell Jr Date: Sat, 16 Nov 2024 20:58:10 -0500 Subject: [PATCH 3/5] Add local array with locale codes for checking path validity instead of using a regex --- server/locales/locales.js | 73 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 server/locales/locales.js diff --git a/server/locales/locales.js b/server/locales/locales.js new file mode 100644 index 0000000000..91fd86cb41 --- /dev/null +++ b/server/locales/locales.js @@ -0,0 +1,73 @@ +export const localeArray = [ + 'af', + 'am', + 'ar', + 'as', + 'az', + 'bg', + 'bn', + 'bs-ba', + 'ca', + 'cs', + 'da', + 'de', + 'el', + 'en', + 'eo', + 'es', + 'et', + 'eu-es', + 'fa', + 'fi', + 'fr', + 'ga-ie', + 'fu-in', + 'he', + 'hi-in', + 'hr', + 'ht-ht', + 'hu', + 'hy', + 'id', + 'is-is', + 'it', + 'ja', + 'kk', + 'km-kh', + 'kn', + 'ko', + 'lt', + 'lv', + 'mk-mk', + 'ml', + 'mn', + 'mr', + 'nb', + 'nl', + 'nn', + 'or', + 'pa', + 'pl', + 'pt', + 'pt-br', + 'ro', + 'ru', + 'si', + 'sk', + 'sl', + 'sr', + 'sr-latn', + 'sv', + 'ta', + 'te', + 'th', + 'tr', + 'ug', + 'uk', + 'ur', + 'vi', + 'zh', + 'zh-tw' +] +export default class localeArrary { +} From 25c2e066672bd32ee41fb12c8bdb42c0386735eb Mon Sep 17 00:00:00 2001 From: Brian Powell Jr Date: Sun, 17 Nov 2024 14:30:10 -0500 Subject: [PATCH 4/5] Updated localeSegmentRegex expression to not filter segments that don't match individual living languages as acknowledged by ISO 639-1. Removed locales.js file as no longer needed --- server/helpers/page.js | 3 +- server/locales/locales.js | 73 --------------------------------------- 2 files changed, 2 insertions(+), 74 deletions(-) delete mode 100644 server/locales/locales.js diff --git a/server/helpers/page.js b/server/helpers/page.js index 8bea0aa3b2..3337c4a821 100644 --- a/server/helpers/page.js +++ b/server/helpers/page.js @@ -3,7 +3,8 @@ const _ = require('lodash') const crypto = require('crypto') const path = require('path') -const localeSegmentRegex = /^[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-z]{2}(?:-[a-z]{2})?\/)?(.*)/i // eslint-disable-next-line no-control-regex const unsafeCharsRegex = /[\x00-\x1f\x80-\x9f\\"|<>:*?]/ diff --git a/server/locales/locales.js b/server/locales/locales.js deleted file mode 100644 index 91fd86cb41..0000000000 --- a/server/locales/locales.js +++ /dev/null @@ -1,73 +0,0 @@ -export const localeArray = [ - 'af', - 'am', - 'ar', - 'as', - 'az', - 'bg', - 'bn', - 'bs-ba', - 'ca', - 'cs', - 'da', - 'de', - 'el', - 'en', - 'eo', - 'es', - 'et', - 'eu-es', - 'fa', - 'fi', - 'fr', - 'ga-ie', - 'fu-in', - 'he', - 'hi-in', - 'hr', - 'ht-ht', - 'hu', - 'hy', - 'id', - 'is-is', - 'it', - 'ja', - 'kk', - 'km-kh', - 'kn', - 'ko', - 'lt', - 'lv', - 'mk-mk', - 'ml', - 'mn', - 'mr', - 'nb', - 'nl', - 'nn', - 'or', - 'pa', - 'pl', - 'pt', - 'pt-br', - 'ro', - 'ru', - 'si', - 'sk', - 'sl', - 'sr', - 'sr-latn', - 'sv', - 'ta', - 'te', - 'th', - 'tr', - 'ug', - 'uk', - 'ur', - 'vi', - 'zh', - 'zh-tw' -] -export default class localeArrary { -} From 9f35f59f613b3407d8f9421d558844f524aa8df7 Mon Sep 17 00:00:00 2001 From: Brian Powell Jr Date: Sun, 17 Nov 2024 15:18:24 -0500 Subject: [PATCH 5/5] Updated localeFolderRegex to match localeSegmentRegex --- server/helpers/page.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/helpers/page.js b/server/helpers/page.js index 3337c4a821..8d5e69260e 100644 --- a/server/helpers/page.js +++ b/server/helpers/page.js @@ -5,7 +5,7 @@ const path = require('path') // 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-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\\"|<>:*?]/