Skip to content

Commit c6df96a

Browse files
committed
Finish 1.0
Let's go!!!
1 parent f40e244 commit c6df96a

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

index.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
const fs=require("fs");
22
const db=JSON.parse(fs.readFileSync("spellcheck.json").toString());
33
const applyCorrections=function(input) {
4-
let inputOut=input;
4+
let output=input;
55
let loopCount=0;
66
Object.keys(db).forEach(entryName => {
7-
let entry=dbJSON[entryName];
8-
9-
while(inputOut.includes(entryName)) {
10-
loopCount++;
11-
if(loopCount==100) {
12-
console.warn("SpellCheckJS has run 100 times.");
7+
let entry=db[entryName];
8+
while(output.includes(entryName)) {
9+
loopCount++;
10+
if(loopCount==100) {
11+
console.warn("SpellCheckJS has run 100 times.");
12+
}
13+
else if(loopCount==200) {
14+
console.warn("SpellCheckJS has run 200 times. You may have supplied maliciously crafted data to the function.");
15+
}
16+
output=output.replace(entryName,entry);
1317
}
14-
else if(loopCount==200) {
15-
console.warn("SpellCheckJS has run 200 times. You may have supplied maliciously crafted data to the function.");
16-
}
17-
fileTextOut=fileTextOut.replace(entryName,entry);
18-
}
19-
// This while loop is where the biggest risk is. With a malicious entry, a user could dOS clients by repetitively increasing input length. Thus the need for thorough submission review.
20-
});
18+
// This while loop is where the biggest risk is. With a malicious entry, a user could dOS clients by repetitively increasing input length. Thus the need for thorough submission review.
19+
});
20+
return output;
2121
};
2222
const SpellCheckJS={
2323
db,
2424
applyCorrections
25-
};
25+
};
26+
module.exports=SpellCheckJS;

0 commit comments

Comments
 (0)