Bumps [github.com/go-acme/lego/v4](https://github.com/go-acme/lego) from 4.4.0 to 4.25.2. - [Release notes](https://github.com/go-acme/lego/releases) - [Changelog](https://github.com/go-acme/lego/blob/master/CHANGELOG.md) - [Commits](https://github.com/go-acme/lego/compare/v4.4.0...v4.25.2) --- updated-dependencies: - dependency-name: github.com/go-acme/lego/v4 dependency-version: 4.25.2 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com>
41 lines
967 B
Go
41 lines
967 B
Go
// Copyright (c) 2015-present Jeevanandam M (jeeva@myjeeva.com)
|
|
// 2024 Ahuigo (https://github.com/ahuigo)
|
|
// All rights reserved.
|
|
// resty source code and usage is governed by a MIT style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
/*
|
|
Package shellescape provides the methods to escape arbitrary
|
|
strings for a safe use as command line arguments in the most common
|
|
POSIX shells.
|
|
|
|
The original Python package which this work was inspired by can be found
|
|
at https://pypi.python.org/pypi/shellescape.
|
|
*/
|
|
package shellescape
|
|
|
|
import (
|
|
"regexp"
|
|
"strings"
|
|
)
|
|
|
|
var pattern *regexp.Regexp
|
|
|
|
func init() {
|
|
pattern = regexp.MustCompile(`[^\w@%+=:,./-]`)
|
|
}
|
|
|
|
// Quote method returns a shell-escaped version of the string. The returned value
|
|
// can safely be used as one token in a shell command line.
|
|
func Quote(s string) string {
|
|
if len(s) == 0 {
|
|
return "''"
|
|
}
|
|
|
|
if pattern.MatchString(s) {
|
|
return "'" + strings.ReplaceAll(s, "'", "'\"'\"'") + "'"
|
|
}
|
|
|
|
return s
|
|
}
|