summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/luasrc/view/cbi
diff options
context:
space:
mode:
authorDaniel Dickinson <openwrt@daniel.thecshore.com>2015-12-01 23:02:38 -0500
committerDaniel Dickinson <openwrt@daniel.thecshore.com>2015-12-15 13:09:41 -0500
commit6509e007e29f438d74b01eb6e23a09f02775dd6c (patch)
tree2cd540822a0b1a73a504d351664af36f6778ad9b /modules/luci-base/luasrc/view/cbi
parent63155e99325d2f7b57eee99496648e7a3cf6c14b (diff)
luci-base: Make default for FileUpload 'safe'
Some files and pointers to files are not safe to remove without a replacement file and config pointing to the file. For instance for uhttpd application in the works, removing the certificate or key config or files without having the replacements in places renders the WeUI inaccessible. The only other place where FileUpload is currently used is for wifi certificates for which the 'safe' handling is also preferred. Therefore make the default for the FileUpload widget the safe handling and add a property self.unsafeupload that allows for the old unsafe handling should it prove useful in some case. Also allow to specify a file already on router instead of uploading a file. Signed-off By: Daniel Dickinson <openwrt@daniel.thecshore.com>
Diffstat (limited to 'modules/luci-base/luasrc/view/cbi')
-rw-r--r--modules/luci-base/luasrc/view/cbi/upload.htm16
1 files changed, 13 insertions, 3 deletions
diff --git a/modules/luci-base/luasrc/view/cbi/upload.htm b/modules/luci-base/luasrc/view/cbi/upload.htm
index 7770934111..157f3b36fa 100644
--- a/modules/luci-base/luasrc/view/cbi/upload.htm
+++ b/modules/luci-base/luasrc/view/cbi/upload.htm
@@ -6,9 +6,19 @@
<%+cbi/valueheader%>
<% if s then %>
<%:Uploaded File%> (<%=t.byte_format(s.size)%>)
- <input type="hidden"<%= attr("value", v) .. attr("name", cbid) .. attr("id", cbid) %> />
- <input class="cbi-button cbi-input-image" type="image" value="<%:Replace entry%>" name="cbi.rlf.<%=section .. "." .. self.option%>" alt="<%:Replace entry%>" title="<%:Replace entry%>" src="<%=resource%>/cbi/reload.gif" />
- <% else %>
+ <% if self.unsafeupload then %>
+ <input type="hidden"<%= attr("value", v) .. attr("name", cbid) .. attr("id", cbid) %> />
+ <input class="cbi-button cbi-input-image" type="image" value="<%:Replace entry%>" name="cbi.rlf.<%=section .. "." .. self.option%>" alt="<%:Replace entry%>" title="<%:Replace entry%>" src="<%=resource%>/cbi/reload.gif" />
+ <% end %>
+ <% end %>
+
+ <% if not self.unsafeupload then %>
+ <input type="hidden"<%= attr("value", v) .. attr("name", "cbi.rlf." .. section .. "." .. self.option) .. attr("id", "cbi.rlf." .. section .. "." .. self.option) %> />
+ <% end %>
+
+ <% if (not s) or (s and not self.unsafeupload) then %>
<input class="cbi-input-file" type="file"<%= attr("name", cbid) .. attr("id", cbid) %> />
<% end %>
+ <input type="text" class="cbi-input-text" onchange="cbi_d_update(this.id)"<%=
+ attr("name", cbid .. ".textbox") .. attr("id", cbid .. ".textbox") .. attr("value", luci.cbi.AbstractValue.cfgvalue(self, section) or self.default) .. ifattr(self.size, "size") .. ifattr(self.placeholder, "placeholder") .. ifattr(self.readonly, "readonly") .. ifattr(self.maxlength, "maxlength") %> />
<%+cbi/valuefooter%>