Remove globals
Clean up a bunch of places where the global namespace was being polluted by accident.
This commit is contained in:
parent
6cd786be1a
commit
1f5b113daa
|
@ -12,7 +12,7 @@ local util = require("util")
|
||||||
|
|
||||||
local ret = {}
|
local ret = {}
|
||||||
|
|
||||||
local stmnt_cache, stmnt_insert_cache
|
local stmnt_cache, stmnt_insert_cache, stmnt_dirty_cache
|
||||||
|
|
||||||
local oldconfigure = configure
|
local oldconfigure = configure
|
||||||
function configure(...)
|
function configure(...)
|
||||||
|
@ -59,7 +59,7 @@ function ret.render(pagename,callback)
|
||||||
stmnt_cache:reset()
|
stmnt_cache:reset()
|
||||||
--page is not cached
|
--page is not cached
|
||||||
elseif err == sql.ROW then
|
elseif err == sql.ROW then
|
||||||
data = stmnt_cache:get_values()
|
local data = stmnt_cache:get_values()
|
||||||
stmnt_cache:reset()
|
stmnt_cache:reset()
|
||||||
return data[1]
|
return data[1]
|
||||||
else --sql.ERROR or sql.MISUSE
|
else --sql.ERROR or sql.MISUSE
|
||||||
|
@ -84,7 +84,7 @@ function ret.dirty(url)
|
||||||
stmnt_dirty_cache:bind_names{
|
stmnt_dirty_cache:bind_names{
|
||||||
path = url
|
path = url
|
||||||
}
|
}
|
||||||
err = util.do_sql(stmnt_dirty_cache)
|
util.do_sql(stmnt_dirty_cache)
|
||||||
stmnt_dirty_cache:reset()
|
stmnt_dirty_cache:reset()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ local cache = require("cache")
|
||||||
local config = require("config")
|
local config = require("config")
|
||||||
local session = require("session")
|
local session = require("session")
|
||||||
|
|
||||||
local stmnt_author_of, stmnt_update_raw, stmnt_update
|
local stmnt_author_of, stmnt_update_raw, stmnt_update, stmnt_hash
|
||||||
|
|
||||||
local oldconfigure = configure
|
local oldconfigure = configure
|
||||||
function configure(...)
|
function configure(...)
|
||||||
|
|
|
@ -94,6 +94,7 @@ end
|
||||||
local function author_paste(req,ps)
|
local function author_paste(req,ps)
|
||||||
--Author paste
|
--Author paste
|
||||||
local author, authorid = session.get(req)
|
local author, authorid = session.get(req)
|
||||||
|
local ret
|
||||||
if author == nil then
|
if author == nil then
|
||||||
ret = pages.author_paste{
|
ret = pages.author_paste{
|
||||||
domain = config.domain,
|
domain = config.domain,
|
||||||
|
@ -114,7 +115,7 @@ local function author_paste(req,ps)
|
||||||
assert(stmnt_paste:bind_blob(5,"") == sql.OK)
|
assert(stmnt_paste:bind_blob(5,"") == sql.OK)
|
||||||
util.sqlbind(stmnt_paste,"bind",6,ps.unlisted)
|
util.sqlbind(stmnt_paste,"bind",6,ps.unlisted)
|
||||||
util.sqlbind(stmnt_paste,"bind_blob",7,textsha3)
|
util.sqlbind(stmnt_paste,"bind_blob",7,textsha3)
|
||||||
err = util.do_sql(stmnt_paste)
|
local err = util.do_sql(stmnt_paste)
|
||||||
stmnt_paste:reset()
|
stmnt_paste:reset()
|
||||||
if err == sql.DONE then
|
if err == sql.DONE then
|
||||||
local rowid = stmnt_paste:last_insert_rowid()
|
local rowid = stmnt_paste:last_insert_rowid()
|
||||||
|
@ -193,7 +194,6 @@ local function paste_post(req)
|
||||||
text = zlib.compress(text)
|
text = zlib.compress(text)
|
||||||
assert(text,"Failed to compress text")
|
assert(text,"Failed to compress text")
|
||||||
ps.text = text
|
ps.text = text
|
||||||
local esctitle = util.decodeentities(title)
|
|
||||||
--Always sanatize the title with the plain parser. no markup
|
--Always sanatize the title with the plain parser. no markup
|
||||||
--in the title.
|
--in the title.
|
||||||
ps.title = parsers.plain(title)
|
ps.title = parsers.plain(title)
|
||||||
|
|
|
@ -5,7 +5,7 @@ local util = require("util")
|
||||||
local queries = require("queries")
|
local queries = require("queries")
|
||||||
|
|
||||||
local oldconfigure = configure
|
local oldconfigure = configure
|
||||||
local stmnt_get_session, stmnt_insert_session
|
local stmnt_get_session, stmnt_insert_session, stmnt_delete_session
|
||||||
function configure(...)
|
function configure(...)
|
||||||
stmnt_get_session = assert(db.conn:prepare(queries.select_valid_sessions))
|
stmnt_get_session = assert(db.conn:prepare(queries.select_valid_sessions))
|
||||||
stmnt_insert_session = assert(db.conn:prepare(queries.insert_session))
|
stmnt_insert_session = assert(db.conn:prepare(queries.insert_session))
|
||||||
|
|
|
@ -169,13 +169,7 @@ function util.parse_tags(str)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function decodeentity(capture)
|
local function decodeentity(capture)
|
||||||
local n = tonumber(capture,16)
|
return string.char(tonumber(capture,16)) --Decode base 16 and conver to character
|
||||||
local c = string.char(n)
|
|
||||||
if escapes[c] then
|
|
||||||
return escapes[c]
|
|
||||||
else
|
|
||||||
return c
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
function util.decodeentities(str)
|
function util.decodeentities(str)
|
||||||
return string.gsub(str,"%%(%x%x)",decodeentity)
|
return string.gsub(str,"%%(%x%x)",decodeentity)
|
||||||
|
|
Loading…
Reference in New Issue