Skip to content

Method SanitizePythonString

Namespace: Belay.Core.Security
Assembly: Belay.Core.dll

SanitizePythonString(string?, bool)

Sanitizes a string for safe use in Python string literals. Enhanced version of the existing EscapePythonString method.

csharp
public static string SanitizePythonString(string? input, bool useDoubleQuotes = false)

Parameters

input string?

The string to sanitize.

useDoubleQuotes bool

Whether to escape for double quotes instead of single quotes.

Returns

string

The sanitized string safe for Python string literals.

Released under the Apache License 2.0.