From 596833180e99ed32cd0e8a1b73481929920ed52d Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 19 Apr 2019 21:08:15 -0400 Subject: [PATCH] fix: block single letter pages + RTL admin label in dark mode fix --- client/components/admin/admin-locale.vue | 2 +- server/helpers/page.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/components/admin/admin-locale.vue b/client/components/admin/admin-locale.vue index 45114fc9..ef6e3d0f 100644 --- a/client/components/admin/admin-locale.vue +++ b/client/components/admin/admin-locale.vue @@ -112,7 +112,7 @@ v-list-tile-title(v-html='lc.name') v-list-tile-sub-title(v-html='lc.nativeName') v-list-tile-action(v-if='lc.isRTL') - v-chip(label, small).caption.grey--text.text--darken-2 RTL + v-chip(label, small, :class='$vuetify.dark ? `text--lighten-5` : `text--darken-2`').caption.grey--text RTL v-list-tile-action(v-if='lc.isInstalled && lc.installDate < lc.updatedAt', @click='download(lc.code)') v-icon.blue--text cached v-list-tile-action(v-else-if='lc.isInstalled') diff --git a/server/helpers/page.js b/server/helpers/page.js index 34517e9a..9b3c7cb2 100644 --- a/server/helpers/page.js +++ b/server/helpers/page.js @@ -2,6 +2,9 @@ const qs = require('querystring') const _ = require('lodash') const crypto = require('crypto') +const localeSegmentRegex = /^[A-Z]{2}(-[A-Z]{2})?$/gi +const systemSegmentRegex = /^[A-Z]\//gi + module.exports = { /** * Parse raw url path and make it safe @@ -24,7 +27,7 @@ module.exports = { if (pathParts[0].length === 1) { pathParts.shift() } - if (pathParts[0].length === 2) { + if (localeSegmentRegex.test(pathParts[0])) { pathObj.locale = pathParts[0] pathParts.shift() } @@ -61,6 +64,6 @@ module.exports = { * Check if path is a reserved path */ isReservedPath(rawPath)  { - return _.some(WIKI.data.reservedPaths, p => _.startsWith(rawPath, p)) + return _.some(WIKI.data.reservedPaths, p => _.startsWith(rawPath, p)) || systemSegmentRegex.test(rawPath) } }