Normalize line endings from textareas

Every day for us something new.
This commit is contained in:
Timotej Lazar 2023-06-26 11:49:26 +02:00
parent 5ba9c03e23
commit fb1c328893
2 changed files with 2 additions and 2 deletions

View file

@ -33,7 +33,7 @@ def edit(name):
return flask.Response('forbidden', status=403, mimetype='text/plain') return flask.Response('forbidden', status=403, mimetype='text/plain')
if flask.request.method == 'POST': if flask.request.method == 'POST':
form = flask.request.form form = flask.request.form
db.save(name, json.loads(form.get('text'))) db.save(name, json.loads(form.get('text').replace('\r\n', '\n')))
system.run(system.save_config) system.run(system.save_config)
content = json.dumps(db.load(name), indent=2) content = json.dumps(db.load(name), indent=2)
return flask.render_template('config/edit.html', **locals()) return flask.render_template('config/edit.html', **locals())

View file

@ -43,7 +43,7 @@ def edit(index):
form = flask.request.form form = flask.request.form
rules = db.read('rules') rules = db.read('rules')
rules[index]['name'] = form.get('name') rules[index]['name'] = form.get('name')
rules[index]['text'] = form.get('text') rules[index]['text'] = form.get('text').replace('\r\n', '\n')
rules[index]['managers'] = [m for m in form.getlist('manager') if m] rules[index]['managers'] = [m for m in form.getlist('manager') if m]
db.write('rules', rules) db.write('rules', rules)
system.run(system.save_config) system.run(system.save_config)