Escape string.
@param  string $input
@param  bool   $quote
@return string
@throws Oppa\Agent\AgentException
554943
public function escapeString(string $input, bool $quote = true): string
    {
        $resourceType = $this->resource->getType();
        $resourceObject = $this->resource->getObject();
        if ($resourceType == Resource::TYPE_MYSQL_LINK) {
            $input = $resourceObject->escape_string($input);
        } elseif ($resourceType == Resource::TYPE_PGSQL_LINK) {
            $input = pg_escape_string($resourceObject, $input);
        }

        if ($quote) {
            $input = $this->quote($input);
        }

        return $input;
    }
977860
public function escape($text, $extra = false)
	{
		$this->connect();

		$result = mysqli_real_escape_string($this->getConnection(), $text);

		if ($extra)
		{
			$result = addcslashes($result, '%_');
		}

		return $result;
	}
206136
public static function escape($inp) {
        if(is_array($inp)) {
            return array_map(__METHOD__, $inp);
        }

        if(!empty($inp) && is_string($inp)) {
            return str_replace(
                ['\\', "\0", "\n", "\r", "'", '"', "\x1a"], ['\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'], $inp
            );
        }
        return $inp;
    }
376870
protected String escapeAndQuote(String s)
    {
        String tmp;

        if (s == null)
        {
            return "\"\"";
        }

        tmp = s;
        tmp = tmp.replaceAll("\\\\", "\\\\\\\\");
        tmp = tmp.replaceAll("\\\"", "\\\\\"");
        tmp = tmp.replaceAll("\\\n", ""); // filter newline
        return "\"" + tmp + "\""; // add quotes
    }
831
def escape(self, text, quote = True):
        
        if isinstance(text, bytes):
            return escape_b(text, quote)
        else:
            return escape(text, quote)
1294766
def escape_b(s, quote=True):
    ''''''
    s = s.replace(b"&", b"&amp;") # Must be done first!
    s = s.replace(b"<", b"&lt;")
    s = s.replace(b">", b"&gt;")
    if quote:
        s = s.replace(b'"', b"&quot;")
    return s
512648
public static function escapeToken($token, $force = false)
    {
        $escaped = preg_replace(self::RE_SPECIALS, '\\\\\\0', $token);

        if ($force || preg_match('/ /', $escaped) || strlen($token) != strlen($escaped)) {
            return '"' . $escaped . '"';
        } else {
            return $escaped;
        }
    }
600238
public static function escape($text)
    {
        $tagregexp = implode('|', array_map('preg_quote', static::_list()));
        preg_match_all('/(.?){(' . $tagregexp . ')\b(.*?)(?:(\/))?}(?:(.+?){\/\2})?(.?)/s', $text, $matches);

        foreach ($matches[0] as $ht) {
            $replace = str_replace_once('{', '{{', $ht);
            $replace = str_replace_last('}', '}}', $replace);
            $text = str_replace($ht, $replace, $text);
        }

        return $text;
    }
1243420
public static String escape(String text) {
        boolean hasQuote = text.indexOf(QUOTE) >= 0;
        boolean hasComma = text.indexOf(COMMA) >= 0;

        if (!(hasQuote || hasComma)) {
            return text;
        }

        StringBuilder builder = new StringBuilder();

        if (hasQuote) {
            for (int i = 0; i < text.length(); i++) {
                char c = text.charAt(i);

                if (c == QUOTE) {
                    builder.append(QUOTE_ESCAPED);
                } else {
                    builder.append(c);
                }
            }
        } else {
            builder.append(text);
        }

        if (hasComma) {
            builder.insert(0, QUOTE);
            builder.append(QUOTE);
        }
        return builder.toString();
    }
708457
def escape_string(self, string):
        """"""
        if self.quote:
            quote = self.quote
        else:
            found = QUOTE_REGEX.search(string)
            quote = STRING_QUOTES[found.group()] if found else next(iter(STRING_QUOTES))

        for match, seq in ESCAPE_SUBS.items():
            if match == quote or match not in STRING_QUOTES:
                string = string.replace(match, seq)

        return f'{quote}{string}{quote}'
134350
public function renderText($text, bool $escape = true): string
    {
        if ($escape) {
            $text = $this->esc($text);
        }
        return (string) Container::getMarkdown()->text((string) $text);
    }
557931
final public function escapeStringForLike(string $inputString, string $escapeChar) : string
    {
        return preg_replace(
            '~([' . preg_quote($this->getLikeWildcardCharacters() . $escapeChar, '~') . '])~u',
            addcslashes($escapeChar, '\\') . '$1',
            $inputString
        );
    }
1125035
public static String escape(String value, char quote) {
    Map<CharSequence, CharSequence> lookupMap = new HashMap<>();
    lookupMap.put(Character.toString(quote), "\\" + quote);
    lookupMap.put("\\", "\\\\");

    final CharSequenceTranslator escape =
        new LookupTranslator(lookupMap)
                .with(new LookupTranslator(EntityArrays.JAVA_CTRL_CHARS_ESCAPE))
                .with(JavaUnicodeEscaper.outsideOf(32, 0x7f));

    return quote + escape.translate(value) + quote;
  }
53959
public static String escapeForReplaceAll(final String input) {
        return input == null ? null : java.util.regex.Matcher.quoteReplacement(input);
    }
1245929
public function sanitize(string $input) : string
    {
        $input = $this->_connection->getConnection()->quote($input);

        return substr($input, 1, -1);
    }
438429
public static String escapeString(String input) {
        StringBuilder escaped = new StringBuilder(input.length() + 10);
        escaped.append('"');
        for (int i = 0; i < input.length(); i++) {
            if (input.charAt(i) == '"') {
                escaped.append("\"\"");
            } else {
                escaped.append(input.charAt(i));
            }
        }
        escaped.append('"');
        return escaped.toString();
    }
1161645
public final function prepareIdentifier(string $input, $inputParam): string
    {
        if (empty($inputParam)) {
            if (strpos($input, '%n') !== false) {
                throw new AgentException('Found %n operator but no replacement parameter given!');
            } elseif (strpos($input, '??') !== false) {
                throw new AgentException('Found ?? operator but no replacement parameter given!');
            }
        } else {
            $input = $this->prepare($input, (array) $inputParam);

            // eg: ('@a.id=?', 1), ('@a.id=@b.id')
            // eg: ('??=?', ['a.id',1]), ('??=??', ['a.id','b.id'])
            // eg: ('a.id=?, a.b=?', [1,2]), ('a.id=??, a.b=?', ['b.id',2])
            if (strpos($input, '=')) {
                $input = implode(', ', array_map(function ($input) {
                    $input = trim($input);
                    if ($input != '') {
                        $input = array_map('trim', explode('=', $input));
                        $input = $this->escapeIdentifier($input[0]) .' = '. (
                            ($input[1] && $input[1][0] == '@' )
                                ? $this->escapeIdentifier($input[1]) : $input[1]
                        );
                        return $input;
                    }
                }, explode(',', $input)));
            }

            return $input;
        }

        // eg: (a.id = 1), (a.id = @b.id)
        if (strpos($input, '=')) {
            $input = implode(', ', array_map(function ($input) {
                $input = trim($input);
                if ($input != '') {
                    $input = array_map('trim', explode('=', $input));
                    $input = $this->escapeIdentifier($input[0]) .' = '. (
                        ($input[1] && $input[1][0] == '@' )
                            ? $this->escapeIdentifier($input[1]) : $this->escape($input[1])
                    );
                    return $input;
                }
            }, explode(',', $input)));
        } else {
            // eg: a.id
            $input = $this->escapeIdentifier($input);
        }

        return $input;
    }