Skip to content

Commit

Permalink
Added an escape character, to fix #36
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhargav-Rao committed Jan 7, 2019
1 parent d4ac663 commit 12406db
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions copypasta.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ def get_post(post_id):
date_one=datetime.fromtimestamp(float(data["date_one"])),
date_two=datetime.fromtimestamp(float(data["date_two"])),
body_one=get_body(data["body_one"]), body_two=get_body(data["body_two"]),
f_body_one=unescape(data["body_one"]).replace("`", "\\`").replace("</script>", "<//script>"),
f_body_two=unescape(data["body_two"]).replace("`", "\\`").replace("</script>", "<//script>"),
f_body_one=get_escaped_body(data["body_one"]),
f_body_two=get_escaped_body(data["body_two"]),
username_one=data["username_one"], username_two=data["username_two"],
user_url_one=data["user_url_one"], user_url_two=data["user_url_two"],
type="Reposted" if data["user_url_one"] != '' and
Expand Down Expand Up @@ -190,6 +190,10 @@ def get_feedback_stats():
"conf": conf_feedback})


def get_escaped_body(body):
return unescape(body).replace("`", "\\`").replace("</script>", "<//script>").replace("${", "$\\{")


def get_body(body):
return unescape(body).split("\r\n")

Expand Down
8 changes: 4 additions & 4 deletions static/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
function disp(one, other)
{

one.replace("<//script>", "</script>")
other.replace("<//script>", "</script>")
one=one.replace("<//script>", "</script>").replace("$//{", "${")
other=other.replace("<//script>", "</script>").replace("$//{", "${")

var color = '',
span = null;
Expand All @@ -31,8 +31,8 @@ display.appendChild(fragment);
function disp_sbs(one, other)
{

one.replace("<//script>", "</script>")
other.replace("<//script>", "</script>")
one=one.replace("<//script>", "</script>").replace("$/{", "${")
other=other.replace("<//script>", "</script>").replace("$/{", "${")

var color = '',
span = null;
Expand Down

0 comments on commit 12406db

Please sign in to comment.