Mercurial Hosting > luan
comparison src/luan/host/main.luan @ 1422:e48290f3d9fb
better quoting
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 17 Nov 2019 16:28:51 -0700 |
parents | 732b5de211fc |
children | d9a5405a3102 |
comparison
equal
deleted
inserted
replaced
1421:8ab2f0fc3829 | 1422:e48290f3d9fb |
---|---|
6 local try = Luan.try or error() | 6 local try = Luan.try or error() |
7 local Io = require "luan:Io.luan" | 7 local Io = require "luan:Io.luan" |
8 local Rpc = require "luan:Rpc.luan" | 8 local Rpc = require "luan:Rpc.luan" |
9 local Thread = require "luan:Thread.luan" | 9 local Thread = require "luan:Thread.luan" |
10 local String = require "luan:String.luan" | 10 local String = require "luan:String.luan" |
11 local literal = String.literal or error() | 11 local regex_quote = String.regex_quote or error() |
12 local lower = String.lower or error() | 12 local lower = String.lower or error() |
13 local matches = String.matches or error() | 13 local matches = String.matches or error() |
14 local Hosted = require "luan:host/Hosted.luan" | 14 local Hosted = require "luan:host/Hosted.luan" |
15 local Logging = require "luan:logging/Logging.luan" | 15 local Logging = require "luan:logging/Logging.luan" |
16 local logger = Logging.logger "main" | 16 local logger = Logging.logger "main" |
112 dir.mkdir() | 112 dir.mkdir() |
113 return { name = dir.name(), path = dir.to_string(), children = {} } | 113 return { name = dir.name(), path = dir.to_string(), children = {} } |
114 end | 114 end |
115 | 115 |
116 local function security(site_dir,file) | 116 local function security(site_dir,file) |
117 matches( file.to_string(), "^"..literal(site_dir.to_string()) ) or error "security violation" | 117 matches( file.to_string(), "^"..regex_quote(site_dir.to_string()) ) or error "security violation" |
118 end | 118 end |
119 | 119 |
120 function fns.copy_file(domain,password,dir,name,content) | 120 function fns.copy_file(domain,password,dir,name,content) |
121 local site_dir = get_dir(domain,password) | 121 local site_dir = get_dir(domain,password) |
122 site_dir or error "domain not found" | 122 site_dir or error "domain not found" |