applications/openvpn: properly handle invalid names when defining new instances
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 11 Aug 2009 16:00:26 +0000 (16:00 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 11 Aug 2009 16:00:26 +0000 (16:00 +0000)
applications/luci-openvpn/luasrc/model/cbi/openvpn.lua

index c220b10a56ee60e03368527dbe294da6dca8d28b..1d055a683efedefd5a2bd5c1d6ad637a7095571b 100644 (file)
@@ -53,16 +53,20 @@ function s.create(self, name)
                self.sectiontype .. ".select"
        )
 
-       uci:section(
-               "openvpn", "openvpn", name,
-               uci:get_all( "openvpn_recipes", recipe )
-       )
+       if name and not name:match("[^a-zA-Z0-9_]") then
+               uci:section(
+                       "openvpn", "openvpn", name,
+                       uci:get_all( "openvpn_recipes", recipe )
+               )
 
-       uci:delete("openvpn", name, "_role")
-       uci:delete("openvpn", name, "_description")
-       uci:save("openvpn")
+               uci:delete("openvpn", name, "_role")
+               uci:delete("openvpn", name, "_description")
+               uci:save("openvpn")
 
-       luci.http.redirect( self.extedit:format(name) )
+               luci.http.redirect( self.extedit:format(name) )
+       else
+               self.invalid_cts = true
+       end
 end