Internal helper to sanitize message output
483917
def _clean_message(message):
    ''''''
    message = message.replace('zonecfg: ', '')
    message = message.splitlines()
    for line in message:
        if line.startswith('On line'):
            message.remove(line)
    return "\n".join(message)
644714
def stderrHandler(level, object, category, file, line, message):
    

    o = ""
    if object:
        o = '"' + object + '"'

    where = "(%s:%d)" % (file, line)

    # level   pid     object   cat      time
    # 5 + 1 + 7 + 1 + 32 + 1 + 17 + 1 + 15 == 80
    safeprintf(sys.stderr, '%s [%5d] %-32s %-17s %-15s ',
               getFormattedLevelName(level), os.getpid(), o, category,
               time.strftime("%b %d %H:%M:%S"))

    try:
        safeprintf(sys.stderr, '%-4s %s %s\n', "", message, where)
    except UnicodeEncodeError:
        # this can happen if message is a unicode object, convert it back into
        # a string using the UTF-8 encoding
        message = message.encode('UTF-8')
        safeprintf(sys.stderr, '%-4s %s %s\n', "", message, where)

    sys.stderr.flush()
1353144
private static void prettyPrintWarningMessage(final List<String> results, final String message) {
        for (final String line: message.split("\\r?\\n")) {
            final StringBuilder builder = new StringBuilder(line);
            while (builder.length() > TEXT_WARNING_WIDTH) {
                int space = getLastSpace(builder, TEXT_WARNING_WIDTH);
                if (space <= 0) space = TEXT_WARNING_WIDTH;
                results.add(String.format("%s%s", TEXT_WARNING_PREFIX, builder.substring(0, space)));
                builder.delete(0, space + 1);
            }
            results.add(String.format("%s%s", TEXT_WARNING_PREFIX, builder));
        }
    }
963963
def _sanitize_params(params)
      Hash[params.map { |key, value| [key.to_sym, _sanitize_value(key, value)] }].freeze
    end
253963
private static String sanitizeText(String text) {
        if (text.indexOf('\r') >= 0) {
            text = CR.matcher(text).replaceAll("");
        }
        if (!text.isEmpty() && !text.endsWith("\n")) {
            text += "\n";
        }
        return text;
    }
647431
def _sanitize_string(unsanitized, itemsep, kvsep):
    
    sanitized = []
    kvs = unsanitized.split(itemsep)
    for kv in kvs:
        kv = kv.split(kvsep)
        if len(kv) == 2:
            sanitized.append((kv[0], _sanitize(kv[0], kv[1])))
        else:
            sanitized.append(kv)
    return itemsep.join(kvsep.join(kv) for kv in sanitized)
1019196
function sanitize(options, blacklist) {
  const opts = Object.assign({}, options);
  const defaults = ['apiurl', 'token', 'username', 'password', 'placeholders', 'bearer'];
  const keys = union([], defaults, blacklist);
  return omit(opts, keys);
}
1054209
private function sanitize() {
        $this->stream = substr($this->stream, $this->cursor);

        // At end of string create a new one
        if($this->stream === false) $this->stream = "";

        // Set brackets back to defaults.
        $this->openingBrackets = $this->closingBrackets = 0;

        // reset cursor. Moving it to where we left off
        // Before we cut down the string size.
        $this->cursor = 0;
    }
1018241
def sanitize(self):
        '''
        
        '''
        super(EncapsulatedControlMessage, self).sanitize()

        # S: This is the Security bit.  When set to 1 the following
        # authentication information will be appended to the end of the Map-
        # Reply.  The detailed format of the Authentication Data Content is
        # for further study.
        if not isinstance(self.security, bool):
            raise ValueError('Security flag must be a boolean')

        if self.security:
            raise NotImplementedError('Handling security data is not ' +
                                      'implemented yet')

        # "D" is the "DDT-originated" flag and is set by a DDT client to
        # indicate that the receiver can and should return Map-Referral
        # messages as appropriate.
        if not isinstance(self.ddt_originated, bool):
            raise ValueError('DDT originated flag must be a boolean')

        # The 6th bit in the ECM LISP header is allocated as the "R"
        # bit.  The R bit indicates that the encapsulated Map-Register is
        # to be processed by an RTR.
        if not isinstance(self.for_rtr, bool):
            raise ValueError('For-RTR flag must be a boolean')

        # The 7th bit in the ECM header is allocated as the "N" bit.  The
        # N bit indicates that this Map-Register is being relayed by an
        # RTR.  When an RTR relays the ECM-ed Map-Register to a Map-Server,
        # the N bit must be set to 1.
        if not isinstance(self.relayed_by_rtr, bool):
            raise ValueError('Relayed-by-RTR flag must be a boolean')
980166
def sanitize(value)
      case value

      when Integer
        value.to_s

      when Numeric, String
        connection.quote value

      when Array
        raise BadValue.new(value, "an empty array") if value.empty?
        raise BadValue.new(value, "a nested array") if value.any? { |v| v.is_a? Array }

        "(" + value.map { |v| sanitize v }.join(", ") + ")"

      when Literal
        value.value

      when Rows # rows for insertion
        value.values.map { |v| sanitize v }.join(", ")

      when Class
        connection.quote value.name

      when DateTime, Time, Date
        enforce_timezone do
          connection.quote value.to_s(:db)
        end

      when true
        connection.quoted_true

      when false
        connection.quoted_false

      when Symbol
        connection.quote value.to_s

      else
        raise BadValue, value
      end
    end
659959
function sanitizeTags(value, telegraf) {
  const blacklist = telegraf ? /:|\|/g : /:|\||@|,/g;
  // Replace reserved chars with underscores.
  return String(value).replace(blacklist, '_');
}
463712
function SanitizeCtx(ctx) {
  let r = {};
  for (const key in ctx) {
    if (!key.startsWith('_')) {
      r[key] = ctx[key];
    }
  }
  return r;
}
226928
function _cleanseInput(dirty){
      var clean = ''
      clean = dirty.replace('@', '')
      clean = clean.replace('#', '')
      clean = clean.replace(/\s/g, '')
      return clean
    }
3343
function sanitizeInput(rawInput) {
   var placeholder = HtmlService.createHtmlOutput(" ");
   placeholder.appendUntrusted(rawInput);
  
   return placeholder.getContent();
 }
1193062
def _clean_flags(args, caller):
    '''
    
    '''
    flags = ''
    if args is None:
        return flags
    allowed = ('a', 'B', 'h', 'H', 'i', 'k', 'l', 'P', 't', 'T', 'x', 'v')
    for flag in args:
        if flag in allowed:
            flags += flag
        else:
            raise CommandExecutionError(
                'Invalid flag passed to {0}'.format(caller)
            )
    return flags
846438
def sanitizeString(name):
    """"""
    newString = name
    # string cleaning, pass 1
    replaceTable = [
        ('^', '^5e'),  # we need to do this one first
        ('"', '^22'),
        ('<', '^3c'),
        ('?', '^3f'),
        ('*', '^2a'),
        ('=', '^3d'),
        ('+', '^2b'),
        ('>', '^3e'),
        ('|', '^7c'),
        (',', '^2c'),
    ]

    #   "   hex 22           <   hex 3c           ?   hex 3f
    #   *   hex 2a           =   hex 3d           ^   hex 5e
    #   +   hex 2b           >   hex 3e           |   hex 7c
    #   ,   hex 2c

    for r in replaceTable:
        newString = newString.replace(r[0], r[1])
    # replace ascii 0-32
    for x in range(0, 33):
        # must add somewhat arbitrary num to avoid conflict at deSanitization
        # conflict example: is ^x1e supposed to be ^x1 (ascii 1) followed by
        # letter 'e' or really ^x1e (ascii 30)
        newString = newString.replace(
            chr(x), hex(x + sanitizerNum).replace('0x', '^'))

    replaceTable2 = [
        ("/", "="),
        (":", "+"),
        (".", ","),
    ]

    # / -> =
    # : -> +
    # . -> ,

    # string cleaning pass 2
    for r in replaceTable2:
        newString = newString.replace(r[0], r[1])
    return newString
779441
def sanitize_args(cmd: List[str]) -> List[str]:
    
    sanitized = []
    for idx, fieldname in enumerate(cmd):
        def _is_password(cmdstr):
            return 'wifi-sec.psk' in cmdstr\
                or 'password' in cmdstr.lower()
        if idx > 0 and _is_password(cmd[idx-1]):
            sanitized.append('****')
        else:
            sanitized.append(fieldname)
    return sanitized