Browse Source

fix: block single letter pages + RTL admin label in dark mode fix

Nick 6 years ago
parent
commit
596833180e
2 changed files with 6 additions and 3 deletions
  1. 1 1
      client/components/admin/admin-locale.vue
  2. 5 2
      server/helpers/page.js

+ 1 - 1
client/components/admin/admin-locale.vue

@@ -112,7 +112,7 @@
                         v-list-tile-title(v-html='lc.name')
                         v-list-tile-title(v-html='lc.name')
                         v-list-tile-sub-title(v-html='lc.nativeName')
                         v-list-tile-sub-title(v-html='lc.nativeName')
                       v-list-tile-action(v-if='lc.isRTL')
                       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-list-tile-action(v-if='lc.isInstalled && lc.installDate < lc.updatedAt', @click='download(lc.code)')
                         v-icon.blue--text cached
                         v-icon.blue--text cached
                       v-list-tile-action(v-else-if='lc.isInstalled')
                       v-list-tile-action(v-else-if='lc.isInstalled')

+ 5 - 2
server/helpers/page.js

@@ -2,6 +2,9 @@ const qs = require('querystring')
 const _ = require('lodash')
 const _ = require('lodash')
 const crypto = require('crypto')
 const crypto = require('crypto')
 
 
+const localeSegmentRegex = /^[A-Z]{2}(-[A-Z]{2})?$/gi
+const systemSegmentRegex = /^[A-Z]\//gi
+
 module.exports = {
 module.exports = {
   /**
   /**
    * Parse raw url path and make it safe
    * Parse raw url path and make it safe
@@ -24,7 +27,7 @@ module.exports = {
     if (pathParts[0].length === 1) {
     if (pathParts[0].length === 1) {
       pathParts.shift()
       pathParts.shift()
     }
     }
-    if (pathParts[0].length === 2) {
+    if (localeSegmentRegex.test(pathParts[0])) {
       pathObj.locale = pathParts[0]
       pathObj.locale = pathParts[0]
       pathParts.shift()
       pathParts.shift()
     }
     }
@@ -61,6 +64,6 @@ module.exports = {
    * Check if path is a reserved path
    * Check if path is a reserved path
    */
    */
   isReservedPath(rawPath)  {
   isReservedPath(rawPath)  {
-    return _.some(WIKI.data.reservedPaths, p => _.startsWith(rawPath, p))
+    return _.some(WIKI.data.reservedPaths, p => _.startsWith(rawPath, p)) || systemSegmentRegex.test(rawPath)
   }
   }
 }
 }