Fix typo in CSP Report-To header name
authorThomas Citharel <tcit@tcit.fr>
Fri, 4 Nov 2022 08:43:13 +0000 (09:43 +0100)
committerThomas Citharel <tcit@tcit.fr>
Fri, 4 Nov 2022 14:02:13 +0000 (15:02 +0100)
The header name was Report-To, not Reply-To.

In any case, that's now being changed to the Reporting-Endpoints HTTP
Response Header.
https://w3c.github.io/reporting/#header
https://github.com/w3c/reporting/issues/177

CanIUse says the Report-To header is still supported by current Chrome
and friends.
https://caniuse.com/mdn-http_headers_report-to

It doesn't have any data for the Reporting-Endpoints HTTP header, but
this article says Chrome 96 supports it.
https://web.dev/reporting-api/

(Even though that's come out one year ago, that's not compatible with
Network Error Logging which's still using the Report-To version of the
API)

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
lib/pleroma/web/plugs/http_security_plug.ex
test/pleroma/web/plugs/http_security_plug_test.exs

index d1e6cc9d3f03f00c7f19dc475345714641711812..3e8e931d1aca3325d414293ff02892cd97b697da 100644 (file)
@@ -68,7 +68,7 @@ defmodule Pleroma.Web.Plugs.HTTPSecurityPlug do
         ]
       }
 
-      [{"reply-to", Jason.encode!(report_group)} | headers]
+      [{"report-to", Jason.encode!(report_group)} | headers]
     else
       headers
     end
index 4e7befdd5345a89ad6b803ff1c3e1608c3ab3a5c..eb94cd665ae8964197bd330eeb1a966d36affa4b 100644 (file)
@@ -59,9 +59,9 @@ defmodule Pleroma.Web.Plugs.HTTPSecurityPlugTest do
 
       assert csp =~ ~r|report-uri https://endpoint.com;report-to csp-endpoint;|
 
-      [reply_to] = Conn.get_resp_header(conn, "reply-to")
+      [report_to] = Conn.get_resp_header(conn, "report-to")
 
-      assert reply_to ==
+      assert report_to ==
                "{\"endpoints\":[{\"url\":\"https://endpoint.com\"}],\"group\":\"csp-endpoint\",\"max-age\":10886400}"
     end