luci-app-openvpn: fix openvpn config corruption on upload 5732/head
authorAnna Tikhomirova <vamp@vampik.ru>
Sat, 19 Mar 2022 23:24:42 +0000 (02:24 +0300)
committerAnna Tikhomirova <vamp@vampik.ru>
Sat, 19 Mar 2022 23:24:42 +0000 (02:24 +0300)
Signed-off-by: Anna Tikhomirova <vamp@vampik.ru>
applications/luci-app-openvpn/luasrc/controller/openvpn.lua
applications/luci-app-openvpn/luasrc/model/cbi/openvpn-file.lua

index a30ac81a99df60970b1bfb1c630a209cf2c74883..b41fff21dcf6e4f1eca63ee8260cefcdaf8a3684 100644 (file)
@@ -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")
index fa823964acf65a70369f8a8a6467573bdc41975f..7197f45ef6854a6e3df7e5e842b784dad3c56b2a 100644 (file)
@@ -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)