Comparing version 2.0.7 to 2.0.8
26
index.js
@@ -11,2 +11,23 @@ const fetch = require("node-fetch"); | ||
// useless functions | ||
function isSafeCatName(str) { | ||
for (let c of str) { | ||
try { | ||
c.match(/[A-Za-z0-9]/); | ||
let thing = c.match(/[A-Za-z0-9]/); | ||
if (!thing || thing === null) { | ||
return false; | ||
} | ||
} catch { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
function isSafePath(path) { | ||
let p = path.split("."); | ||
for (let pp of p) { | ||
if (!isSafeCatName(pp)) return false; | ||
} | ||
return true; | ||
} | ||
function redo(str) { | ||
@@ -84,2 +105,7 @@ return str.slice(1, str.length - 1); | ||
if (isArr(gjov(this.subreddits, curp))) { | ||
if (!isSafePath(curp)) { | ||
throw new Error( | ||
"UnsafeCategoryName: One of the category names in the subreddits.json file was seen as unsafe.\nMake sure you use a trusted trevlist or the default one to avoid this error.\nRules for making a category name safe: only letters (caps or no caps) and numbers" | ||
); | ||
} | ||
varstore[tableplace] = gjov(this.subreddits, curp); | ||
@@ -86,0 +112,0 @@ eval(` |
{ | ||
"name": "trev", | ||
"version": "2.0.7", | ||
"version": "2.0.8", | ||
"description": "Getting random nsfw images, hentai images and memes from reddit. Fast and tons of features supported.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
22909
794