From 9ece0daa7664bafcebdad062c29813cf0ea5b178 Mon Sep 17 00:00:00 2001
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Sun, 4 Feb 2018 18:47:58 +0100
Subject: [PATCH] gluon-web: ListValue: convert keys to strings before adding
 to key list

Fixes validation of ListValues.

Fixes: ec532b95 "gluon-web: extend ListValue with optional and unset
values"
---
 package/gluon-web/luasrc/usr/lib/lua/gluon/web/model.lua | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/package/gluon-web/luasrc/usr/lib/lua/gluon/web/model.lua b/package/gluon-web/luasrc/usr/lib/lua/gluon/web/model.lua
index 27aee3250..ee841024b 100644
--- a/package/gluon-web/luasrc/usr/lib/lua/gluon/web/model.lua
+++ b/package/gluon-web/luasrc/usr/lib/lua/gluon/web/model.lua
@@ -401,14 +401,16 @@ function ListValue:__init__(...)
 end
 
 function ListValue:value(key, val, ...)
+	key = tostring(key)
+
 	if self.keys[key] then
 		return
 	end
+	self.keys[key] = true
 
 	val = val or key
-	self.keys[key] = true
 	table.insert(self.entry_list, {
-		key = tostring(key),
+		key = key,
 		value = tostring(val),
 		deps = {...},
 	})
-- 
GitLab