-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathapi.go
More file actions
33 lines (29 loc) · 722 Bytes
/
api.go
File metadata and controls
33 lines (29 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package shellescape
import (
"al.essio.dev/pkg/shellescape"
lua "github.com/yuin/gopher-lua"
)
func Quote(L *lua.LState) int {
str := L.CheckString(1)
escapedStr := shellescape.Quote(str)
L.Push(lua.LString(escapedStr))
return 1
}
func QuoteCommand(L *lua.LState) int {
args := L.CheckTable(1)
argsLen := args.Len()
goArgs := make([]string, argsLen)
for i := 0; i < argsLen; i++ {
goArgs[i] = lua.LVAsString(args.RawGetInt(i + 1))
}
L.Pop(L.GetTop())
quotedCommand := shellescape.QuoteCommand(goArgs)
L.Push(lua.LString(quotedCommand))
return 1
}
func StripUnsafe(L *lua.LState) int {
str := L.CheckString(1)
strippedStr := shellescape.StripUnsafe(str)
L.Push(lua.LString(strippedStr))
return 1
}