fix invalid lang bug

This commit is contained in:
orenom
2021-05-13 17:40:56 +02:00
parent 2c8669ca03
commit df046c5335
3 changed files with 13 additions and 3 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ Many countries have censored Wikipedia pages, including China, France, Germany,
### 2: What's the problem of Wikipedia getting my IP address?
**Short:** If you trust that Wikipedia has not been infiltrated and/or you don't trust the Wikiless instance you would use, then you probably want to keep using Wikipedia instead of Wikiless because there are nothing to worry about giving IP address to Wikipedia.
**Short:** If you trust that Wikipedia has not been infiltrated and/or you don't trust the Wikiless instance you would use, then you probably want to keep using Wikipedia instead of Wikiless because there are nothing to worry about giving your IP address to Wikipedia.
**Long:** We know from the leaks by Edward Snowden that the U.S. National Security Agency (NSA) has identified Wikipedia as a target for surveillance already in 2009.\[1\]\[2\] Wikimedia filled a lawsuit against the NSA in 2015 in order to fight against the mass-surveillance done by the NSA.\[2\]\[3\]
+1 -1
View File
@@ -79,7 +79,7 @@ module.exports = (app, utils) => {
app.post('/preferences', (req, res, next) => {
let theme = req.body.theme
let default_lang = req.body.default_lang
let back = req.query.back
let back = req.url.split('?back=')[1]
res.cookie('theme', theme, { maxAge: 365 * 24 * 60 * 60 * 1000, httpOnly: true })
res.cookie('default_lang', default_lang, { maxAge: 365 * 24 * 60 * 60 * 1000, httpOnly: true })
+11 -1
View File
@@ -251,6 +251,14 @@ module.exports = function(redis) {
this.handleWikiPage = async (req, res, prefix) => {
let lang = req.query.lang || req.cookies.default_lang || config.default_lang
if(lang) {
if(typeof(lang) !== 'string') {
lang = lang[0]
} else {
lang = lang.split('?')[0]
}
}
if(!validLang(lang)) {
return res.send('invalid lang')
}
@@ -385,6 +393,8 @@ module.exports = function(redis) {
lang_select += '</select>'
let back = req.url.split('?back=')[1]
let html = `
<!DOCTYPE html>
<html lang="en">
@@ -397,7 +407,7 @@ module.exports = function(redis) {
<body>
<div id="preferences">
<h4>Preferences</h4>
<form method="POST" action="/preferences?back=${req.query.back}">
<form method="POST" action="/preferences?back=${back}">
<div class="setting">
<label for="theme">Theme:</label>
<select id="theme" name="theme">