From 64b80b8f118753930357a236ce96ed5e4d720cda Mon Sep 17 00:00:00 2001 From: Anna Tikhomirova Date: Sun, 20 Mar 2022 02:24:42 +0300 Subject: [PATCH] luci-app-openvpn: fix openvpn config corruption on upload Signed-off-by: Anna Tikhomirova --- applications/luci-app-openvpn/luasrc/controller/openvpn.lua | 3 +-- .../luci-app-openvpn/luasrc/model/cbi/openvpn-file.lua | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/applications/luci-app-openvpn/luasrc/controller/openvpn.lua b/applications/luci-app-openvpn/luasrc/controller/openvpn.lua index a30ac81a99..b41fff21dc 100644 --- a/applications/luci-app-openvpn/luasrc/controller/openvpn.lua +++ b/applications/luci-app-openvpn/luasrc/controller/openvpn.lua @@ -31,8 +31,7 @@ function ovpn_upload() http.setfilehandler( function(meta, chunk, eof) - local data = util.trim(chunk:gsub("\r\n", "\n")) .. "\n" - data = util.trim(data:gsub("[\128-\255]", "")) + local data = chunk:gsub("\r\n", "\n") if not fp and meta and meta.name == "ovpn_file" then fp = io.open(file, "w") diff --git a/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-file.lua b/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-file.lua index fa823964ac..7197f45ef6 100644 --- a/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-file.lua +++ b/applications/luci-app-openvpn/luasrc/model/cbi/openvpn-file.lua @@ -51,7 +51,7 @@ function file.cfgvalue() end function file.write(self, section, data1) - return fs.writefile(cfg_file, "\n" .. util.trim(data1:gsub("\r\n", "\n")) .. "\n") + return fs.writefile(cfg_file, util.trim(data1:gsub("\r\n", "\n")) .. "\n") end function file.remove(self, section, value) -- 2.30.2