sanitise input (can't believe I just remembered this)
This commit is contained in:
parent
68068adfa3
commit
b2c649d001
19
app.js
19
app.js
@ -78,6 +78,17 @@ function replace_format_indicators(input_string, post_index=0, tag_name="tag") {
|
||||
return output_string
|
||||
}
|
||||
|
||||
function escape_input(input) {
|
||||
let output = input
|
||||
.replaceAll("<", "<")
|
||||
.replaceAll(">", ">")
|
||||
.replaceAll("\\", "\")
|
||||
.replaceAll('"', """)
|
||||
.replaceAll("'", "'")
|
||||
.replaceAll("/", "/")
|
||||
return output
|
||||
}
|
||||
|
||||
app.get(config.rss_path, (req,res) => {
|
||||
if (config.rss == false) {
|
||||
res.send("Sorry, RSS is disabled!")
|
||||
@ -227,10 +238,10 @@ app.post("/submit_edit", (req,res) => {
|
||||
});
|
||||
app.post("/submit_post", (req,res) => {
|
||||
const password = crypto.createHash('sha512').update(req.body.password).digest('hex');
|
||||
const username = req.body.username
|
||||
const title = req.body.title
|
||||
const content = req.body.content
|
||||
const tags = req.body.tags.split(',');
|
||||
const username = escape_input(req.body.username)
|
||||
const title = escape_input(req.body.title)
|
||||
const content = escape_input(req.body.content)
|
||||
const tags = escape_input(req.body.tags).split(',');
|
||||
const unix_timestamp = getUnixTime(new Date())
|
||||
console.log(username, "is submitting a post titled:", title);
|
||||
|
||||
|
@ -1 +1 @@
|
||||
15
|
||||
45
|
Loading…
x
Reference in New Issue
Block a user