/*
|--------------------------------------------------------------------------
| Netherlands Post surface mail Parse
|--------------------------------------------------------------------------
772234
function createNLSkyEntity(id, json) {
    let infos = json.message.replace('，', ',').split('<br/>').filter(m => m.length != 0)

    let messages = null

    if(infos[0].indexOf("span") !== -1) { // title
        infos.splice(0, 1) //remove first element
    }

    if(infos[0].indexOf("table") !== -1) {
        let table = infos.splice(0, 1) //remove first element
        messages = parseStatusTable(table[0])
    }

    let parsedStatus = infos.map(message => {
        let idx1 = message.indexOf(",")
        let idx2 = message.indexOf("--", idx1+1)
        let area = message.substr(0, idx1)
        let status = message.substr(idx1+1, idx2 - idx1 - 1)
        let date = moment.tz(message.substr(idx2 + 2), "DD-MMM-YYYY hh:mm a", zone).format()
        return {
            area: area,
            status: status.trim().capitalizeFirstLetter(),
            date: date
        }
    })

    return new SkyInfo({
        id: id,
        status: parsedStatus.reverse(),
        messages: messages
    })
}
131967
function parseResponse(response) {
  let text;

  if (response && response.content && (typeof response.content === 'string')) {
    text = response.content;
  }

  if (response && response.text && (typeof response.text === 'string')) {
    text = response.text;
  }

  if (!text) {
    console.error('Did not supply any matching response format. Response is:', text);
    return null;
  }

  try {
    const parsedResponse = JSON.parse(text);

    if (
      parsedResponse
      && parsedResponse.data
      && (parsedResponse.data instanceof Object === true)
    ) {
      return parsedResponse.data;
    }
  } catch (err) {
    console.error('Error while parsing JSON', err);
  }

  return null;
}
461508
function parseUpdateAlertRequest(req){
  var reqObj = {};
  reqObj.originalUrl = req.originalUrl;
  reqObj.alertName = req.body.alertName;
  reqObj.emails = req.body.emails.split(',');
  reqObj.eventCategories = req.body.eventCategories.split(',');
  reqObj.eventNames = req.body.eventNames.split(',');
  reqObj.eventSeverities = req.body.eventSeverities.split(',');
  reqObj.uid = req.body.uid;
  reqObj.env = req.body.env;
  reqObj.alertEnabled = req.body.enabled;
  reqObj._id = req.params.id;
  reqObj.domain = req.params.domain;
  return reqObj;
}
1143606
function(apiKey, contactId, fromName,
        fromAddress, toAddress, ccAddresses, bccAddresses, contentType,
        subject, htmlBody, textBody, header, receivedDate, sentDate,
        emailSentType) {}
656685
function parse(data){
			var out = {source: 'api'};
        	if(data.ok && data.ok === true){

        		var entry = data.user;

        		if(entry.username){ out.nickname = entry.username };
        		if(entry.name){ out.fn = entry.name };
				if(entry.short_bio){ out.note = [entry.short_bio] };

        		if(entry.web_url){ 
        			if(!out.url) {out.url = []};
        			out.url.push(entry.web_url);
        		};

        		if(entry.twitter_url){ 
        			if(!out.url) {out.url = []};
        			out.url.push(entry.twitter_url);
        		};

				if(entry.avatar_url){ 
				  	var large = entry.avatar_url.replace('s48','s300');
					out.photo = [large] 
				};

			}
			return {type: ['h-card'], properties: out};
		}
1135945
@SuppressWarnings("unchecked")
	@Override
	protected StringBuffer doPostProcessBundle(BundleProcessingStatus status, StringBuffer bundleData)
			throws IOException {

		if (LOGGER.isInfoEnabled()) {
			LOGGER.info("Base64 encoding resources - '" + status.getLastPathAdded() + "'");
		}

		Map<String, Base64EncodedResource> encodedResources = (Map<String, Base64EncodedResource>) status
				.getData(JawrConstant.BASE64_ENCODED_RESOURCES);
		if (encodedResources == null) {
			encodedResources = new HashMap<>();
			status.putData(JawrConstant.BASE64_ENCODED_RESOURCES, encodedResources);
		}

		StringBuffer sb = bundleData;
		if (status.getProcessingType().equals(BundleProcessingStatus.FILE_PROCESSING_TYPE)) {
			sb = super.doPostProcessBundle(status, bundleData);
		}

		if (!encodedResources.isEmpty() && status.isSearchingPostProcessorVariants()) {
			VariantSet variantSet = new VariantSet(JawrConstant.BROWSER_VARIANT_TYPE, "",
					new String[] { "", JawrConstant.BROWSER_IE6, JawrConstant.BROWSER_IE7 });
			status.addPostProcessVariant(JawrConstant.BROWSER_VARIANT_TYPE, variantSet);
			variantSet = new VariantSet(JawrConstant.CONNECTION_TYPE_VARIANT_TYPE, "",
					new String[] { "", JawrConstant.SSL });
			status.addPostProcessVariant(JawrConstant.CONNECTION_TYPE_VARIANT_TYPE, variantSet);
		}

		if (!status.isSearchingPostProcessorVariants()
				&& status.getProcessingType().equals(BundleProcessingStatus.BUNDLE_PROCESSING_TYPE)) {

			Map<String, String> bundleVariants = status.getBundleVariants();
			if (bundleVariants != null) {
				String browser = bundleVariants.get(JawrConstant.BROWSER_VARIANT_TYPE);
				if (StringUtils.isNotEmpty(browser)
						&& (JawrConstant.BROWSER_IE6.equals(browser) || JawrConstant.BROWSER_IE7.equals(browser))) {
					prependBase64EncodedResources(sb, encodedResources);
				}
			}
		}

		if (LOGGER.isInfoEnabled()) {
			LOGGER.info("Base64 Postprocessing done");
		}
		return sb;
	}
1015095
function buildEmail(envelope, data) {
  return simpleParser(data)
    .then(function(parsedEmail) {
      const sender    = envelope.mailFrom.address;
      const receivers = envelope.rcptTo
        .map(recipient => [ recipient.address, true ])
        .reduce(tupleToObject, {});

      const headers   = [ ... parsedEmail.headers ]
        .map(readHeader)
        .reduce(tupleToObject, {});

      const email     = {
        sender,
        receivers,
        data,
        headers,
        body:      parsedEmail.text,
        html:      parsedEmail.html,
        attachments:      parsedEmail.attachments
      };

      return email;
    });
}
489837
function getPostQuery(body) {
  if (!body) return {};

  let result = {};
  let commentReg = /^\[(\w+)\]\:([\s|\S]+)/;
  body.split('\r\n').every((item) => {
    let itemMatch = item.match(commentReg);
    if (itemMatch && itemMatch.length == 3) {
      let queryKey = itemMatch[1],
        queryVal = itemMatch[2];
      result[queryKey] = queryVal && queryVal.trim();
      return true;
    } else {
      return false;
    }
  })

  return result;
}
248705
function parseArrayPattern(params, kind) {
        var node = new Node(), elements = [], rest, restNode;
        expect('[');

        while (!match(']')) {
            if (match(',')) {
                lex();
                elements.push(null);
            } else {
                if (match('...')) {
                    restNode = new Node();
                    lex();
                    params.push(lookahead);
                    rest = parseVariableIdentifier(kind);
                    elements.push(restNode.finishRestElement(rest));
                    break;
                } else {
                    elements.push(parsePatternWithDefault(params, kind));
                }
                if (!match(']')) {
                    expect(',');
                }
            }

        }

        expect(']');

        return node.finishArrayPattern(elements);
    }
1286570
function parseArrayElements (parser, responses, i) {
  const bufferLength = parser.buffer.length
  while (i < responses.length) {
    const offset = parser.offset
    if (parser.offset >= bufferLength) {
      pushArrayCache(parser, responses, i)
      return
    }
    const response = parseType(parser, parser.buffer[parser.offset++])
    if (response === undefined) {
      if (!(parser.arrayCache.length || parser.bufferCache.length)) {
        parser.offset = offset
      }
      pushArrayCache(parser, responses, i)
      return
    }
    responses[i] = response
    i++
  }

  return responses
}
689275
function parseCreateAlertRequest(req){

  var reqObj = {};
  reqObj.originalUrl = req.originalUrl;
  reqObj.alertName = req.body.alertName;
  reqObj.emails = req.body.emails;
  reqObj.eventCategories = req.body.eventCategories.split(',');
  reqObj.eventNames = req.body.eventNames.split(',');
  reqObj.eventSeverities = req.body.eventSeverities.split(',');
  reqObj.uid = req.body.uid;
  reqObj.env = req.body.env;
  reqObj.alertEnabled = req.body.enabled;
  reqObj._id = new Mongoose.Types.ObjectId();
  reqObj.domain = req.params.domain;
  return reqObj;
}
1154106
protected function _parseAddress()
    {
        $start = $this->_ptr;
        if (!$this->_parseGroup()) {
            $this->_ptr = $start;
            if ($mbox = $this->_parseMailbox()) {
                $this->_listob->add($mbox);
            }
        }
    }
173641
function checkPostOrPutOrPatchRequest(req, res, cb) {
            var _keys;
            var _reqElement;

            if (req.body) {
                _keys = Object.keys(req.body);
                _keys.forEach(function (keyElement) {
                    _reqElement = req.body[keyElement];
                    //console.log(/" [a-z]*="/i.spec(_reqElement));
                    _patterns.forEach(function (pattern) {
                        if (pattern.test(_reqElement) && _blocker.blockHost) {
                            _config.attack.handle(req, res);
                        }
                    });
                });
            }
            if (cb) {
                cb();
            }
        }
190499
function UTF8ArrToStr (aBytes) {

  var sView = "";

  for (var nPart, nLen = aBytes.length, nIdx = 0; nIdx < nLen; nIdx++) {
    nPart = aBytes[nIdx];
    sView += String.fromCharCode(
      nPart > 251 && nPart < 254 && nIdx + 5 < nLen ? /* six bytes */
        /* (nPart - 252 << 32) is not possible in ECMAScript! So...: */
        (nPart - 252) * 1073741824 + (aBytes[++nIdx] - 128 << 24) + (aBytes[++nIdx] - 128 << 18) + (aBytes[++nIdx] - 128 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128
      : nPart > 247 && nPart < 252 && nIdx + 4 < nLen ? /* five bytes */
        (nPart - 248 << 24) + (aBytes[++nIdx] - 128 << 18) + (aBytes[++nIdx] - 128 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128
      : nPart > 239 && nPart < 248 && nIdx + 3 < nLen ? /* four bytes */
        (nPart - 240 << 18) + (aBytes[++nIdx] - 128 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128
      : nPart > 223 && nPart < 240 && nIdx + 2 < nLen ? /* three bytes */
        (nPart - 224 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128
      : nPart > 191 && nPart < 224 && nIdx + 1 < nLen ? /* two bytes */
        (nPart - 192 << 6) + aBytes[++nIdx] - 128
      : /* nPart < 127 ? */ /* one byte */
        nPart
    );
  }

  return sView;

}
198100
def post_parse_action(self, entry):
        """"""
        if 'source_host' in entry.keys():
            host = self.ip_port_regex.findall(entry['source_host'])
            if host:
                hlist = host[0].split('.')
                entry['source_host'] = '.'.join(hlist[:4])
                entry['source_port'] = hlist[-1]
        if 'dest_host' in entry.keys():
            host = self.ip_port_regex.findall(entry['dest_host'])
            if host:
                hlist = host[0].split('.')
                entry['dest_host'] = '.'.join(hlist[:4])
                entry['dest_port'] = hlist[-1]

        return entry
1615
function parsePlatforms() {
        var supportPlatforms = [
            { platform: 'android',          regexp: /android/ig         },
            { platform: 'ios',              regexp: /ios/ig             },
            { platform: 'firefoxos',        regexp: /firefoxos/ig       },
            { platform: 'windows8',         regexp: /windows8/ig        },
            { platform: 'browser',          regexp: /browser/ig         },
            { platform: 'amazon-fireos',    regexp: /amazon-fireos/ig   },
            { platform: 'blackberry10',     regexp: /blackberry10/ig    },
            { platform: 'windows',          regexp: /windows/ig         },
            { platform: 'wp8',              regexp: /wp8/ig             },
        ];

        var gruntTasks = [];

        supportPlatforms.forEach(function (checker) {
            if (null != _cmdline.match(checker.regexp)) {
                gruntTasks.push('cordova_register_platform:' + checker.platform);
            }
        });

        return gruntTasks;
    }
52165
function parseNaptr(val, msg) {
  val.order = msg.readUInt16BE();
  val.preference = msg.readUInt16BE();
  var len = msg.readUInt8();
  val.flags = msg.toString('ascii', len);
  len = msg.readUInt8();
  val.service = msg.toString('ascii', len);
  len = msg.readUInt8();
  val.regexp = msg.toString('ascii', len);
  val.replacement = nameUnpack(msg);
  return PARSE_RESOURCE_DONE;
}