Skip to content

Commit 5f0d043

Browse files
authored
Merge pull request #1053 from dsprenkels/robots.txt
Disallow creation of robots.txt in freeurl
2 parents 6f7fd74 + 4bd8d7e commit 5f0d043

File tree

4 files changed

+5
-1
lines changed

4 files changed

+5
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ There are some config settings you need to change in the files below.
185185
| `CMD_ALLOW_ANONYMOUS` | `true` or `false` | set to allow anonymous usage (default is `true`) |
186186
| `CMD_ALLOW_ANONYMOUS_EDITS` | `true` or `false` | if `allowAnonymous` is `true`, allow users to select `freely` permission, allowing guests to edit existing notes (default is `false`) |
187187
| `CMD_ALLOW_FREEURL` | `true` or `false` | set to allow new note creation by accessing a nonexistent note URL |
188+
| `CMD_FORBIDDEN_NODE_IDS` | `'robots.txt'` | disallow creation of notes, even if `CMD_ALLOW_FREEURL` is `true` |
188189
| `CMD_DEFAULT_PERMISSION` | `freely`, `editable`, `limited`, `locked` or `private` | set notes default permission (only applied on signed users) |
189190
| `CMD_DB_URL` | `mysql://localhost:3306/database` | set the database URL |
190191
| `CMD_SESSION_SECRET` | no example | Secret used to sign the session cookie. If non is set, one will randomly generated on startup |
@@ -284,6 +285,7 @@ There are some config settings you need to change in the files below.
284285
| `allowAnonymous` | `true` or `false` | set to allow anonymous usage (default is `true`) |
285286
| `allowAnonymousEdits` | `true` or `false` | if `allowAnonymous` is `true`: allow users to select `freely` permission, allowing guests to edit existing notes (default is `false`) |
286287
| `allowFreeURL` | `true` or `false` | set to allow new note creation by accessing a nonexistent note URL |
288+
| `forbiddenNoteIDs` | `['robots.txt']` | disallow creation of notes, even if `allowFreeUrl` is `true` |
287289
| `defaultPermission` | `freely`, `editable`, `limited`, `locked`, `protected` or `private` | set notes default permission (only applied on signed users) |
288290
| `dbURL` | `mysql://localhost:3306/database` | set the db URL; if set, then db config (below) won't be applied |
289291
| `db` | `{ "dialect": "sqlite", "storage": "./db.codimd.sqlite" }` | set the db configs, [see more here](http://sequelize.readthedocs.org/en/latest/api/sequelize/) |

lib/config/default.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ module.exports = {
3232
allowAnonymous: true,
3333
allowAnonymousEdits: false,
3434
allowFreeURL: false,
35+
forbiddenNoteIDs: ['robots.txt', 'favicon.ico', 'api'],
3536
defaultPermission: 'editable',
3637
dbURL: '',
3738
db: {},

lib/config/environment.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module.exports = {
2828
allowAnonymous: toBooleanConfig(process.env.CMD_ALLOW_ANONYMOUS),
2929
allowAnonymousEdits: toBooleanConfig(process.env.CMD_ALLOW_ANONYMOUS_EDITS),
3030
allowFreeURL: toBooleanConfig(process.env.CMD_ALLOW_FREEURL),
31+
forbiddenNoteIDs: toArrayConfig(process.env.CMD_FORBIDDEN_NOTE_IDS),
3132
defaultPermission: process.env.CMD_DEFAULT_PERMISSION,
3233
dbURL: process.env.CMD_DB_URL,
3334
sessionSecret: process.env.CMD_SESSION_SECRET,

lib/response.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ function findNote (req, res, callback, include) {
157157
include: include || null
158158
}).then(function (note) {
159159
if (!note) {
160-
if (config.allowFreeURL && noteId) {
160+
if (config.allowFreeURL && noteId && !config.forbiddenNoteIDs.includes(noteId)) {
161161
req.alias = noteId
162162
return newNote(req, res)
163163
} else {

0 commit comments

Comments
 (0)