MCPcopy
hub / github.com/caddyserver/certmagic / Safe

Method Safe

storage.go:269–285  ·  view source on GitHub ↗

Safe standardizes and sanitizes str for use as a single component of a storage key. This method is idempotent.

(str string)

Source from the content-addressed store, hash-verified

267// a single component of a storage key. This method
268// is idempotent.
269func (keys KeyBuilder) Safe(str string) string {
270 str = strings.ToLower(str)
271 str = strings.TrimSpace(str)
272
273 // replace a few specific characters
274 repl := strings.NewReplacer(
275 " ", "_",
276 "+", "_plus_",
277 "*", "wildcard_",
278 ":", "-",
279 "..", "", // prevent directory traversal (regex allows single dots)
280 )
281 str = repl.Replace(str)
282
283 // finally remove all non-word characters
284 return safeKeyRE.ReplaceAllLiteralString(str, "")
285}
286
287// CleanUpOwnLocks immediately cleans up all
288// current locks obtained by this process. Since

Callers 12

CertsPrefixMethod · 0.95
CertsSitePrefixMethod · 0.95
SiteCertMethod · 0.95
SitePrivateKeyMethod · 0.95
SiteMetaMethod · 0.95
OCSPStapleMethod · 0.95
challengeTokensKeyMethod · 0.80
storageKeyACMECAPrefixFunction · 0.80
storageKeyUserPrefixMethod · 0.80
storageSafeUserKeyMethod · 0.80
lockFilenameMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected