Skip to content
Snippets Groups Projects
Unverified Commit 79a49a15 authored by Matthias Schiffer's avatar Matthias Schiffer
Browse files

gluon-luci-theme: add HTML and URL escaping utility functions

parent 81280d8e
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,7 @@ PKG_RELEASE:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
include $(GLUONDIR)/include/package.mk
define Package/gluon-luci-theme
......@@ -31,10 +31,12 @@ define Build/Configure
endef
define Build/Compile
$(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/)
endef
define Package/gluon-luci-theme/install
$(CP) ./files/* $(1)/
$(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
endef
$(eval $(call BuildPackage,gluon-luci-theme))
......@@ -17,6 +17,7 @@ $Id$
local http = require "luci.http"
local disp = require "luci.dispatcher"
local fs = require "nixio.fs"
local gluon_luci = require "gluon.luci"
local hostname = sys.hostname()
local release = fs.readfile("/lib/gluon/release")
......@@ -110,15 +111,15 @@ $Id$
</style>
<% end -%>
<script type="text/javascript" src="<%=resource%>/xhr.js"></script>
<title><%=striptags( hostname .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI</title>
<title><%=gluon_luci.escape( hostname .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI</title>
</head>
<body class="lang_<%=luci.i18n.context.lang%>">
<div id="menubar">
<div class="hostinfo">
<%=hostname%>
<%=gluon_luci.escape(hostname)%>
<% if release then %>
/ <%=release%>
/ <%=gluon_luci.escape(release)%>
<% end %>
<span id="xhr_poll_status" style="display:none" onclick="XHR.running() ? XHR.halt() : XHR.run()">
| <%:Auto Refresh%>:
......
-- Config mode utility functions
local string = string
module 'gluon.luci'
function escape(s)
return (string.gsub(s, '[<>&"]', {
['<'] = '&lt;',
['>'] = '&gt;',
['&'] = '&amp;',
['"'] = '&quot;',
}))
end
function urlescape(s)
return (string.gsub(s, '[^a-zA-Z0-9%-_%.~]',
function(c)
local ret = ''
for i = 1, string.len(c) do
ret = ret .. string.format('%%%02X', string.byte(c, i, i))
end
return ret
end
))
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment