Compare commits

...

1 Commits

Author SHA1 Message Date
08599ce2a3 minor sanitization for post editing 2018-06-21 22:49:25 -04:00
2 changed files with 7 additions and 1 deletions

View File

@ -54,6 +54,7 @@ def new_post(data):
""" """
Called when the QM makes a new post. Called when the QM makes a new post.
""" """
print(data)
room = data["room"] room = data["room"]
res = db.get_quest_meta(quest_id=room) res = db.get_quest_meta(quest_id=room)
if not res: if not res:
@ -83,6 +84,9 @@ def update_post(data):
return return
post = data["post"] post = data["post"]
post = post.strip().replace("<br>", "<br />")
data["post"] = post
post_id = data["post_id"] post_id = data["post_id"]
db.update_quest_post(post_id, post) db.update_quest_post(post_id, post)
emit("update_post", data, room=room) emit("update_post", data, room=room)

View File

@ -3,6 +3,7 @@
{% block head %} {% block head %}
<script type="text/javascript" src="/static/socket.io.slim.js"></script> <script type="text/javascript" src="/static/socket.io.slim.js"></script>
<script> <script>
document.execCommand("defaultParagraphSeparator", false, "br");
var socket; var socket;
var tid = setInterval( function () { var tid = setInterval( function () {
if ( document.readyState !== 'complete' ) return; if ( document.readyState !== 'complete' ) return;
@ -61,7 +62,8 @@
} }
function edit_post(post_id) { function edit_post(post_id) {
document.getElementById('questPostData-' + post_id).contentEditable = 'true'; document.getElementById('questPostData-' + post_id).contentEditable = 'true';
document.getElementById('questPostData-' + post_id).style.border = '1px solid #ccc' document.execCommand("defaultParagraphSeparator", false, "br");
document.getElementById('questPostData-' + post_id).style.border = '1px solid #ccc';
document.getElementById('savePost-' + post_id).style.display = 'initial'; document.getElementById('savePost-' + post_id).style.display = 'initial';
} }
function save_post(post_id) { function save_post(post_id) {