Unverified Commit 813df210 authored by broxen's avatar broxen Committed by GitHub

fix: prevent malformed paths for pages (#4533)

* First take on removing erroneous path characters Paths should not accept trailing slashes or hashtags. This is a first attempt at nullifying those. * Use rules to verify path before acceptance Use Regex and rules to verify paths before acceptance * Rules to prevent any leading or trailing slashes * Complex slug for regex on path, but it elminates special chars * Added yarn.lock to .gitignore * Maybe we do want yarn.lock afterall * Adding yarn.lock * Move Regex pattern outside of export
parent e8d56c28
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
:hint='$t(`editor:props.pathHint`)' :hint='$t(`editor:props.pathHint`)'
persistent-hint persistent-hint
@click:append='showPathSelector' @click:append='showPathSelector'
:rules='[rules.required, rules.path]'
) )
v-divider v-divider
v-card-text.grey.pt-5(:class='$vuetify.theme.dark ? `darken-3-d5` : `lighten-4`') v-card-text.grey.pt-5(:class='$vuetify.theme.dark ? `darken-3-d5` : `lighten-4`')
...@@ -254,6 +255,7 @@ import 'codemirror/mode/htmlmixed/htmlmixed.js' ...@@ -254,6 +255,7 @@ import 'codemirror/mode/htmlmixed/htmlmixed.js'
import 'codemirror/mode/css/css.js' import 'codemirror/mode/css/css.js'
/* global siteLangs, siteConfig */ /* global siteLangs, siteConfig */
const filenamePattern = /^(?![\#\/\.\$\^\=\*\;\:\&\?\(\)\[\]\{\}\"\'\>\<\,\@\!\%\`\~\s])(?!.*[\#\/\.\$\^\=\*\;\:\&\?\(\)\[\]\{\}\"\'\>\<\,\@\!\%\`\~\s]$)[^\#\.\$\^\=\*\;\:\&\?\(\)\[\]\{\}\"\'\>\<\,\@\!\%\`\~\s]*$/
export default { export default {
props: { props: {
...@@ -272,7 +274,13 @@ export default { ...@@ -272,7 +274,13 @@ export default {
newTagSuggestions: [], newTagSuggestions: [],
newTagSearch: '', newTagSearch: '',
currentTab: 0, currentTab: 0,
cm: null cm: null,
rules: {
required: value => !!value || 'This field is required.',
path: value => {
return filenamePattern.test(value) || 'Invalid path. Please ensure it does not contain special characters, or begin/end in a slash or hashtag string.'
}
}
} }
}, },
computed: { computed: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment