From 29282b5a7d43e8b5ce12b0ec4b7a7620c19a67b6 Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Mon, 9 Feb 2015 19:44:12 +0200 Subject: proper escaping for back-end addresses --- aconf/transaction/base.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'aconf/transaction') diff --git a/aconf/transaction/base.lua b/aconf/transaction/base.lua index 2bdc963..f40dcca 100644 --- a/aconf/transaction/base.lua +++ b/aconf/transaction/base.lua @@ -1,5 +1,5 @@ --[[ -Copyright (c) 2012-2014 Kaarle Ritvanen +Copyright (c) 2012-2015 Kaarle Ritvanen See LICENSE file for license details --]] @@ -10,7 +10,7 @@ local err = require('aconf.error') local object = require('aconf.object') local class = object.class -local pth = require('aconf.path') +local address = require('aconf.path.address') local copy = require('aconf.util').copy -- TODO each transaction backend (i.e. persistence manager or @@ -130,14 +130,14 @@ function M.Transaction:_set_multiple(mods) for _, mod in ipairs(mods) do local path, value = table.unpack(mod) - local ppath = pth.parent(path) + local ppath = address.parent(path) local parent = self:get(ppath) if parent == nil then parent = {} self:set(ppath, parent) end - local name = pth.name(path) + local name = address.name(path) local old = self:get(path) local is_table = type(value) == 'table' @@ -147,7 +147,9 @@ function M.Transaction:_set_multiple(mods) if type(old) == 'table' then if delete then - for _, child in ipairs(old) do self:set(pth.join(path, child)) end + for _, child in ipairs(old) do + self:set(address.join(path, child)) + end elseif is_table then return elseif #old > 0 then error('Cannot assign a primitive value to non-leaf node '..path) @@ -186,7 +188,7 @@ function M.Transaction:commit() local function insert_add(path) if not handled[path] then - local pp = pth.parent(path) + local pp = address.parent(path) if self.added[pp] then insert_add(pp) end insert(path, self.added[path]) end @@ -197,7 +199,7 @@ function M.Transaction:commit() local value = self.backend:get(path) if type(value) == 'table' then for _, child in ipairs(value) do - local cp = pth.join(path, child) + local cp = address.join(path, child) assert(self.deleted[cp]) insert_del(cp) end -- cgit v1.2.3