gluon-config-mode-*, gluon-luci-*: add escaping for many user- or site-defined strings

Allows weird release numbers, models and site names, and prepares support
for pretty hostnames.
This commit is contained in:
Matthias Schiffer 2016-08-27 12:58:00 +02:00
parent 79a49a1515
commit 819c7d59f1
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
8 changed files with 63 additions and 48 deletions

View File

@ -22,11 +22,11 @@ msgstr ""
"er auf den Servern des Entenhausener Freifunk-Projektes eingetragen wurde, " "er auf den Servern des Entenhausener Freifunk-Projektes eingetragen wurde, "
"kann sich dein Knoten mit dem Entenhausener Mesh-VPN verbinden. Bitte " "kann sich dein Knoten mit dem Entenhausener Mesh-VPN verbinden. Bitte "
"schicke dazu diesen Schlüssel und den Namen deines Knotens " "schicke dazu diesen Schlüssel und den Namen deines Knotens "
"(<em><%=hostname%></em>) an " "(<em><%=escape(hostname)%></em>) an "
"<a href=\"mailto:keys@entenhausen.freifunk.net\">keys@entenhausen.freifunk.net</a>." "<a href=\"mailto:keys@entenhausen.freifunk.net\">keys@entenhausen.freifunk.net</a>."
"</p>" "</p>"
"<div class=\"the-key\">" "<div class=\"the-key\">"
" # <%= hostname %>" " # <%= escape(hostname) %>"
" <br/>" " <br/>"
"<%= pubkey %>" "<%= pubkey %>"
"</div>" "</div>"

View File

@ -20,11 +20,11 @@ msgstr ""
"<p>This is your Freifunk node's public key. The node won't be able to " "<p>This is your Freifunk node's public key. The node won't be able to "
"connect to the mesh VPN until the key has been registered on the Freifunk " "connect to the mesh VPN until the key has been registered on the Freifunk "
"Duckburg servers. " "Duckburg servers. "
"To register, send the key together with your node's name (<em><%=hostname%></em>) to " "To register, send the key together with your node's name (<em><%=escape(hostname)%></em>) to "
"<a href=\"mailto:keys@entenhausen.freifunk.net\">keys@entenhausen.freifunk.net</a>." "<a href=\"mailto:keys@entenhausen.freifunk.net\">keys@entenhausen.freifunk.net</a>."
"</p>" "</p>"
"<div class=\"the-key\">" "<div class=\"the-key\">"
" # <%= hostname %>" " # <%= escape(hostname) %>"
" <br/>" " <br/>"
"<%= pubkey %>" "<%= pubkey %>"
"</div>" "</div>"

View File

@ -22,11 +22,11 @@ msgstr ""
"entrée sur les serveurs de votre groupe de Freifunk votre nœud pourra se connecter " "entrée sur les serveurs de votre groupe de Freifunk votre nœud pourra se connecter "
"sur les serveur Mesh-VPN de votre groupe Freifunk. Veuillez envoyer la clé avec le " "sur les serveur Mesh-VPN de votre groupe Freifunk. Veuillez envoyer la clé avec le "
"nom de votre nœud " "nom de votre nœud "
"(<em><%=hostname%></em>) à " "(<em><%=escape(hostname)%></em>) à "
"<a href=\"mailto:keys@entenhausen.freifunk.net\">keys@entenhausen.freifunk.net</a>." "<a href=\"mailto:keys@entenhausen.freifunk.net\">keys@entenhausen.freifunk.net</a>."
"</p>" "</p>"
"<div class=\"the-key\">" "<div class=\"the-key\">"
" # <%= hostname %>" " # <%= escape(hostname) %>"
" <br/>" " <br/>"
"<%= pubkey %>" "<%= pubkey %>"
"</div>" "</div>"

View File

@ -1,4 +1,5 @@
<%- <%-
local gluon_luci = require 'gluon.luci'
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local i18n = require 'luci.i18n' local i18n = require 'luci.i18n'
local template = require 'luci.template' local template = require 'luci.template'
@ -6,7 +7,12 @@
<h2><%:Welcome!%></h2> <h2><%:Welcome!%></h2>
<p> <p>
<%= template.render_string(i18n.translate('gluon-config-mode:welcome'), {hostname=hostname, sysconfig=sysconfig}) %> <%= template.render_string(i18n.translate('gluon-config-mode:welcome'), {
hostname = hostname,
sysconfig = sysconfig,
escape = gluon_luci.escape,
urlescape = gluon_luci.urlescape,
}) %>
</p> </p>
<% if not self.embedded then %> <% if not self.embedded then %>

View File

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%=luci.i18n.context.lang%>" lang="<%=luci.i18n.context.lang%>"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%=luci.i18n.context.lang%>" lang="<%=luci.i18n.context.lang%>">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><%=hostname%> is rebooting</title> <title><%=escape(hostname)%> is rebooting</title>
<link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/cascade.css" /> <link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/cascade.css" />
</head> </head>
<body> <body>

View File

@ -48,6 +48,7 @@ function action_reboot()
uci:save("gluon-setup-mode") uci:save("gluon-setup-mode")
uci:commit("gluon-setup-mode") uci:commit("gluon-setup-mode")
local gluon_luci = require "gluon.luci"
local fs = require "nixio.fs" local fs = require "nixio.fs"
local util = require "nixio.util" local util = require "nixio.util"
@ -73,6 +74,8 @@ function action_reboot()
{ {
parts = parts, parts = parts,
hostname = hostname, hostname = hostname,
escape = gluon_luci.escape,
urlescape = gluon_luci.urlescape,
} }
) )

View File

@ -6,6 +6,8 @@ if meshvpn_enabled ~= "1" then
else else
local i18n = require "luci.i18n" local i18n = require "luci.i18n"
local util = require "luci.util" local util = require "luci.util"
local gluon_luci = require 'gluon.luci'
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
@ -16,11 +18,14 @@ else
local msg = i18n.translate('gluon-config-mode:pubkey') local msg = i18n.translate('gluon-config-mode:pubkey')
return function () return function ()
luci.template.render_string(msg, { pubkey=pubkey luci.template.render_string(msg, {
, hostname=hostname pubkey = pubkey,
, site=site hostname = hostname,
, sysconfig=sysconfig site = site,
, contact=contact sysconfig = sysconfig,
contact = contact,
escape = gluon_luci.escape,
urlescape = gluon_luci.urlescape,
}) })
end end
end end

View File

@ -4,6 +4,7 @@
local util = require 'luci.util' local util = require 'luci.util'
local i18n = require 'luci.i18n' local i18n = require 'luci.i18n'
local gluon_luci = require "gluon.luci"
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local platform = require 'gluon.platform' local platform = require 'gluon.platform'
@ -40,6 +41,6 @@
<h2><%:Information%></h2> <h2><%:Information%></h2>
<% for _, key in ipairs({'hostname', 'primary_mac', 'model', 'version', 'release', 'site', 'pubkey'}) do %> <% for _, key in ipairs({'hostname', 'primary_mac', 'model', 'version', 'release', 'site', 'pubkey'}) do %>
<div class="cbi-value"> <div class="cbi-value">
<div class="cbi-value-title"><%=keys[key]%></div><div class="cbi-value-field"><%=values[key] or 'n/a'%></div> <div class="cbi-value-title"><%=keys[key]%></div><div class="cbi-value-field"><%=gluon_luci.escape(values[key] or 'n/a')%></div>
</div> </div>
<% end %> <% end %>