option to replace spaces in filename:

merge-requests/208/head
fatchan 4 years ago
parent 06703c4743
commit 569398a2e4
  1. 3
      configs/main.js.example
  2. 6
      controllers/forms.js
  3. 8
      package-lock.json

@ -138,6 +138,9 @@ module.exports = {
true=allow only A-Za-z0-9_- true=allow only A-Za-z0-9_-
regex=custom regex of what to replace e.g. /[^\w\s-]+/g */ regex=custom regex of what to replace e.g. /[^\w\s-]+/g */
filterFileNames: false, filterFileNames: false,
/* replace spaces and multiple spaces with some character default _ for better filenames
(spaces dont belong in filenames) */
spaceFileNameReplacement: '_',
//options for code block highlighting in posts //options for code block highlighting in posts
highlightOptions: { highlightOptions: {

@ -3,7 +3,7 @@
const express = require('express') const express = require('express')
, router = express.Router() , router = express.Router()
, Boards = require(__dirname+'/../db/boards.js') , Boards = require(__dirname+'/../db/boards.js')
, { globalLimits, debugLogs, filterFileNames } = require(__dirname+'/../configs/main.js') , { globalLimits, debugLogs, filterFileNames, spaceFileNameReplacement } = require(__dirname+'/../configs/main.js')
//middlewares //middlewares
, calcPerms = require(__dirname+'/../helpers/checks/calcpermsmiddleware.js') , calcPerms = require(__dirname+'/../helpers/checks/calcpermsmiddleware.js')
, hasPerms = require(__dirname+'/../helpers/checks/haspermsmiddleware.js') , hasPerms = require(__dirname+'/../helpers/checks/haspermsmiddleware.js')
@ -29,6 +29,7 @@ const express = require('express')
debug: debugLogs, debug: debugLogs,
createParentPath: true, createParentPath: true,
safeFileNames: filterFileNames, safeFileNames: filterFileNames,
spaceFileNameReplacement,
preserveExtension: 4, preserveExtension: 4,
limits: { limits: {
totalSize: globalLimits.postFilesSize.max, totalSize: globalLimits.postFilesSize.max,
@ -43,7 +44,8 @@ const express = require('express')
debug: debugLogs, debug: debugLogs,
createParentPath: true, createParentPath: true,
safeFileNames: filterFileNames, safeFileNames: filterFileNames,
preserveExtension: 3, spaceFileNameReplacement,
preserveExtension: 4,
limits: { limits: {
totalSize: globalLimits.bannerFilesSize.max, totalSize: globalLimits.bannerFilesSize.max,
fileSize: globalLimits.bannerFilesSize.max, fileSize: globalLimits.bannerFilesSize.max,

8
package-lock.json generated

@ -226,7 +226,7 @@
} }
}, },
"@tohru/gm": { "@tohru/gm": {
"version": "github:fatchan/gm#c2ffb2ce0db3f64fbf4082462601429985b6dca6", "version": "github:fatchan/gm#07df8fbf131b6b18c32fa010a84e67964e132955",
"from": "github:fatchan/gm", "from": "github:fatchan/gm",
"requires": { "requires": {
"array-parallel": "^0.1.3", "array-parallel": "^0.1.3",
@ -2401,8 +2401,8 @@
} }
}, },
"express-fileupload": { "express-fileupload": {
"version": "github:fatchan/express-fileupload#fd713ae7a3c7f381638d6479faa142d366304329", "version": "github:fatchan/express-fileupload#9aada2ecdef8a6617ccf82746e5faa2aece77239",
"from": "github:fatchan/express-fileupload#fd713ae7a3c7f381638d6479faa142d366304329", "from": "github:fatchan/express-fileupload",
"requires": { "requires": {
"busboy": "^0.3.1" "busboy": "^0.3.1"
} }
@ -3604,7 +3604,7 @@
} }
}, },
"gm": { "gm": {
"version": "github:fatchan/gm#c2ffb2ce0db3f64fbf4082462601429985b6dca6", "version": "github:fatchan/gm#07df8fbf131b6b18c32fa010a84e67964e132955",
"from": "github:fatchan/gm", "from": "github:fatchan/gm",
"requires": { "requires": {
"array-parallel": "^0.1.3", "array-parallel": "^0.1.3",

Loading…
Cancel
Save