We need to parse the padding and type as soon as possible,
        else we won't be able to parse the message list...
2358
def pre_dissect(self, s):
        
        if len(s) < 1:
            raise Exception("Invalid InnerPlaintext (too short).")

        tmp_len = len(s) - 1
        if s[-1] != b"\x00":
            msg_len = tmp_len
        else:
            n = 1
            while s[-n] != b"\x00" and n < tmp_len:
                n += 1
            msg_len = tmp_len - n
        self.fields_desc[0].length_from = lambda pkt: msg_len

        self.type = struct.unpack("B", s[msg_len:msg_len + 1])[0]

        return s
558865
def process_message(message_text):
    
    message_text = normalize_message(message_text)
    for (regex, data_lambda) in TEMPLATES:
        match = regex.search(message_text)
        if match:
            result = Request(**data_lambda(match))
            return result
1122432
@Override
    protected void parse() {
        confirmDropMessage = getBoolean(PARAM_CONFIRM_DROP_MESSAGE_KEY, false);
        buttonMode = getInt(PARAM_UI_BUTTON_MODE, BUTTON_MODE_SIMPLE);
        alwaysOnTop = getConfig().getBoolean(PARAM_BRK_ALWAYS_ON_TOP, null);
        inScopeOnly = getBoolean(PARAM_BRK_IN_SCOPE_ONLY, false);
    }
1014211
def _pad_input(incoming):
    
    incoming_expanded = incoming.replace('{', '{{').replace('}', '}}')
    for key in _BASE_CODES:
        before, after = '{{%s}}' % key, '{%s}' % key
        if before in incoming_expanded:
            incoming_expanded = incoming_expanded.replace(before, after)
    return incoming_expanded
489756
def _pad(self, data):
        
        length = 16 - (len(data) % 16)
        data += chr(length)*length
        return data
1268908
public void setPadding(@Nullable String paddingString) {
        if (!TextUtils.isEmpty(paddingString)) {
            // remove leading and ending '[' ']'
            try {
                paddingString = paddingString.trim().substring(1, paddingString.length() - 1);
                String paddingStringArray[] = paddingString.split(",");
                int size = paddingStringArray.length > 4 ? 4 : paddingStringArray.length;
                for (int i = 0; i < size; i++) {
                    String paddingStr = paddingStringArray[i];
                    try {
                        if (!TextUtils.isEmpty(paddingStr)) {
                            padding[i] = parseSize(paddingStr.trim().replace("\"", ""), 0);
                        } else {
                            padding[i] = 0;
                        }
                    } catch (NumberFormatException ignored) {
                        padding[i] = 0;
                    }
                }
                Arrays.fill(padding, size, padding.length, padding[size - 1]);
            } catch (Exception e) {
                Arrays.fill(padding, 0);
            }
        }
    }
696517
def process_content_type(text)
      content = {}

      field_start = text.index(';')

      content['content-type'] = text[0 ... field_start].strip

      parts = text.split(';')

      parts.each do |part|
        (name, value) = part.gsub(/\"/, '').split('=')

        content[name.strip] = value ? value.strip : value
      end

      content
    end
1368108
def _pad(self, b):
        
        return b + (self.bs - len(b) % self.bs) * chr(self.bs - len(b) % self.bs).encode("UTF-8")
1296983
void parseDocument(
            final char[] buffer, final int offset, final int len,
            final IMarkupHandler handler, final ParseStatus status)
            throws ParseException {


        final long parsingStartTimeNanos = System.nanoTime();

        try {

            handler.handleDocumentStart(parsingStartTimeNanos, 1, 1);

            status.offset = -1;
            status.line = 1;
            status.col = 1;
            status.inStructure = false;
            status.parsingDisabled = true;
            status.parsingDisabledLimitSequence = null;
            status.autoCloseRequired = null;
            status.autoCloseLimits = null;

            parseBuffer(buffer, offset, len, handler, status);

            // First parse done, now it's time to clean up in case we still have some text to be notified

            int lastLine = status.line;
            int lastCol = status.col;

            final int lastStart = status.offset;
            final int lastLen = (offset + len) - lastStart;

            if (lastLen > 0) {

                if (status.inStructure) {
                    throw new ParseException(
                            "Incomplete structure: \"" + new String(buffer, lastStart, lastLen) + "\"", status.line, status.col);
                }

                handler.handleText(buffer, lastStart, lastLen, status.line, status.col);

                // As we have produced an additional text event, we need to fast-forward the
                // lastLine and lastCol position to include the last text structure.
                for (int i = lastStart; i < (lastStart + lastLen); i++) {
                    final char c = buffer[i];
                    if (c == '\n') {
                        lastLine++;
                        lastCol = 1;
                    } else {
                        lastCol++;
                    }

                }

            }

            final long parsingEndTimeNanos = System.nanoTime();
            handler.handleDocumentEnd(parsingEndTimeNanos, (parsingEndTimeNanos - parsingStartTimeNanos), lastLine, lastCol);

        } catch (final ParseException e) {
            throw e;
        } catch (final Exception e) {
            throw new ParseException(e);
        }

    }
959545
private void scanText() {

        if (isLetter(mInput)) {
            mOutput.append(mInput);
            mPos++;

        } else {
            mType = TokenType.TEXT;
            mFinnished = true;
        }
    }
636139
def strip_pkcs7_padding(m, block_size):
    
    if len(m) < block_size or len(m) % block_size != 0:
        raise BadPaddingException("Unable to strip padding: invalid message length")

    m = bytearray(m) # py2/3 compatibility: always returns individual indexed elements as ints
    last_byte = m[-1]
    # the <last_byte> bytes of m must all have value <last_byte>, otherwise something's wrong
    if (last_byte <= 0 or last_byte > block_size) or (m[-last_byte:] != bytearray([last_byte])*last_byte):
        raise BadPaddingException("Unable to strip padding: invalid padding found")

    return bytes(m[:-last_byte])
2521
private void parseDelimiter(ByteBuffer buffer) {
        while (__delimiterStates.contains(_state) && hasNextByte(buffer)) {
            HttpTokens.Token t = next(buffer);
            if (t == null)
                return;

            if (t.getType() == HttpTokens.Type.LF) {
                setState(State.BODY_PART);

                if (LOG.isDebugEnabled())
                    LOG.debug("startPart {}", this);

                _handler.startPart();
                return;
            }

            switch (_state) {
                case DELIMITER:
                    if (t.getChar() == '-')
                        setState(State.DELIMITER_CLOSE);
                    else
                        setState(State.DELIMITER_PADDING);
                    continue;

                case DELIMITER_CLOSE:
                    if (t.getChar() == '-') {
                        setState(State.EPILOGUE);
                        return;
                    }
                    setState(State.DELIMITER_PADDING);
                    continue;

                case DELIMITER_PADDING:
                default:
            }
        }
    }
293868
def _parse(self, msg_dict):
        '''
        
        '''
        error_present = False
        # log.debug('Matching the message:')
        # log.debug(msg_dict)
        for message in self.compiled_messages:
            # log.debug('Matching using:')
            # log.debug(message)
            match_on = message['match_on']
            if match_on not in msg_dict:
                # log.debug('%s is not a valid key in the partially parsed dict', match_on)
                continue
            if message['tag'] != msg_dict[match_on]:
                continue
            if '__python_fun__' in message:
                return {
                    'model': message['model'],
                    'error': message['error'],
                    '__python_fun__': message['__python_fun__']
                }
            error_present = True
            match = message['line'].search(msg_dict['message'])
            if not match:
                continue
            positions = message.get('positions', {})
            values = message.get('values')
            ret = {
                'model': message['model'],
                'mapping': message['mapping'],
                'replace': message['replace'],
                'error': message['error']
            }
            for key in values.keys():
                # Check if the value needs to be replaced
                if key in message['replace']:
                    result = napalm_logs.utils.cast(match.group(positions.get(key)), message['replace'][key])
                else:
                    result = match.group(positions.get(key))
                ret[key] = result
            return ret
        if error_present is True:
            log.info('Configured regex did not match for os: %s tag %s', self._name, msg_dict.get('tag', ''))
        else:
            log.info('Syslog message not configured for os: %s tag %s', self._name, msg_dict.get('tag', ''))
85477
function paddingElementForTransform(proper, arr) {
    //RN not support multi font-family keywords
    if (proper === 'font-family') {
        return [proper, arr.pop()]
    }
    //not support such shorthand
    if (proper === 'background') {
        return ['background-color', arr.join(" ")]
    }
    //not support such shorthand
    if (proper === 'border-bottom' || proper === 'border-top' || proper === 'border-right' || proper === 'border-left') {
        // console.warn("not support property",proper)
        return []
    }
    //content property should take just single value
    if (proper === 'content' && arr.length === 1)
        return [proper, arr[0]]
    return [proper, arr.join(" ")]
}
1088993
def process_pad_frame(self,
                          id=None,
                          msg=None):
        

        # normalize into a dataframe
        df = json_normalize(msg)
        # convert to a flattened dictionary
        dt = json.loads(df.to_json())

        flat_msg = {}

        for k in dt:
            new_key = "pad_{}".format(k)
            flat_msg[new_key] = dt[k]["0"]
            if new_key not in self.pad_keys:
                self.pad_keys[new_key] = k
        # end of capturing all unique keys

        dt["pad_id"] = id
        self.all_pad.append(dt)

        log.debug("PAD data updated:")
        log.debug(self.pad_keys)
        log.debug(self.all_pad)
        log.debug("")

        return flat_msg
736126
public void parseLongestText(String text, AhoCorasickDoubleArrayTrie.IHit<V> processor)
    {
        int length = text.length();
        for (int i = 0; i < length; ++i)
        {
            BaseNode<V> state = transition(text.charAt(i));
            if (state != null)
            {
                int to = i + 1;
                int end = to;
                V value = state.getValue();
                for (; to < length; ++to)
                {
                    state = state.transition(text.charAt(to));
                    if (state == null) break;
                    if (state.getValue() != null)
                    {
                        value = state.getValue();
                        end = to + 1;
                    }
                }
                if (value != null)
                {
                    processor.hit(i, end, value);
                    i = end - 1;
                }
            }
        }
    }
1129214
def parse(self, text):
        '''
        '''
        results = []
        if isinstance(text, str):
            if six.PY2:
                text = unicode(text, 'utf-8')
        self.clean_text = self._normalize_string(text)

        # get addresses
        addresses = set(self._get_addresses(self.clean_text))
        if addresses:
            # append parsed address info
            results = list(map(self._parse_address, addresses))

        return results