# HG changeset patch # User Kim Alvefur # Date 1529764635 -7200 # Node ID 03cda95ae97a967267fe003b782671a9ee545c8e # Parent 9817e45a79e6921548c8753f030ff36713d3bdfd mod_pastebin: Prevent header table form being mutated default_headers was mutated, probably by mod_http_errors and ended up with multiple content-type entries, which led to issues in browsers which would sometimes treat the paste as html diff -r 9817e45a79e6 -r 03cda95ae97a mod_pastebin/mod_pastebin.lua --- a/mod_pastebin/mod_pastebin.lua Fri Jun 22 15:19:55 2018 +0200 +++ b/mod_pastebin/mod_pastebin.lua Sat Jun 23 16:37:15 2018 +0200 @@ -51,7 +51,6 @@ trigger_string = (trigger_string and trigger_string .. " "); local pastes = {}; -local default_headers = { ["Content-Type"] = "text/plain; charset=utf-8" }; local xmlns_xhtmlim = "http://jabber.org/protocol/xhtml-im"; local xmlns_xhtml = "http://www.w3.org/1999/xhtml"; @@ -67,14 +66,20 @@ end function handle_request(event, pasteid) - if not pasteid or not pastes[pasteid] then - event.response.headers = default_headers; - return event.response:send("Invalid paste id, perhaps it expired?"); + event.response.headers.content_type = "text/plain; charset=utf-8"; + + if not pasteid then + return "Invalid paste id, perhaps it expired?"; end --module:log("debug", "Received request, replying: %s", pastes[pasteid].text); + local paste = pastes[pasteid]; - return pastes[pasteid]; + if not paste then + return "Invalid paste id, perhaps it expired?"; + end + + return paste.body; end local function replace_tag(s, replacement)