From 8614da63226219ab6422aae194a5cc87a6a7004a Mon Sep 17 00:00:00 2001 From: Nicolas F Date: Sat, 13 Apr 2019 16:13:14 +0200 Subject: [PATCH] view.html: fix comment text copypasting in Firefox Firefox would insert a lot of weird whitespace, because its user-select would default to "all" and not "text", so it copypastes the whitespace of otherwise completely invisible HTML elements. I don't know why Firefox does this. It's stupid, and not what the user expects. They're copying what they see, not what the DOM is. --- nyaa/static/css/main.css | 5 +++++ nyaa/templates/view.html | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/nyaa/static/css/main.css b/nyaa/static/css/main.css index f314f6e..839883d 100644 --- a/nyaa/static/css/main.css +++ b/nyaa/static/css/main.css @@ -293,6 +293,11 @@ a.text-purple:hover, a.text-purple:active, a.text-purple:focus { margin-bottom: 10px; } +/* workaround for Mozilla whitespace copypaste dumbfuckery */ +.comment-body { + -moz-user-select: text; +} + .comment-content { overflow-wrap: break-word; } diff --git a/nyaa/templates/view.html b/nyaa/templates/view.html index e7cb93e..bf32c33 100644 --- a/nyaa/templates/view.html +++ b/nyaa/templates/view.html @@ -174,7 +174,7 @@ {% endif %} -
+
{# Escape newlines into html entities because CF strips blank newlines #}
{{- comment.text | escape | replace('\r\n', '\n') | replace('\n', ' '|safe) -}}
{% if g.user.id == comment.user_id and comment_form %}