Parses the stack trace part of the log entry into an array containing the necessary information

@param  string  $content

@return array
555327
public function parseStackTrace($content)
    {
        $content = trim($content);
        $pattern = "/^".self::STACK_TRACE_INDEX_PATTERN."/m";

        if (empty($content)) {
            return [];
        }

        $traces = preg_split($pattern, $content);

        if (empty($trace[0])) {
            array_shift($traces);
        }

        return $traces;
    }
89507
public function parse($content)
    {
        $this->extend('onBeforeParse', $content);

        $continue = true;

        // If no shortcodes defined, don't try and parse any
        if (!$this->shortcodes) {
            $continue = false;
        } elseif (!trim($content)) {
            // If no content, don't try and parse it
            $continue = false;
        } elseif (strpos($content, '[') === false) {
            // If no shortcode tag, don't try and parse it
            $continue = false;
        }

        if ($continue) {
            // First we operate in text mode, replacing any shortcodes with marker elements so that later we can
            // use a proper DOM
            list($content, $tags) = $this->replaceElementTagsWithMarkers($content);

        /** @var HTMLValue $htmlvalue */
            $htmlvalue = Injector::inst()->create('HTMLValue', $content);

            // Now parse the result into a DOM
            if (!$htmlvalue->isValid()) {
                if (self::$error_behavior == self::ERROR) {
                    user_error('Couldn\'t decode HTML when processing short codes', E_USER_ERROR);
                } else {
                    $continue = false;
                }
            }
        }

        if ($continue) {
            // First, replace any shortcodes that are in attributes
            $this->replaceAttributeTagsWithContent($htmlvalue);

            // Find all the element scoped shortcode markers
            $shortcodes = $htmlvalue->query('//img[@class="' . self::$marker_class . '"]');

            // Find the parents. Do this before DOM modification, since SPLIT might cause parents to move otherwise
            $parents = $this->findParentsForMarkers($shortcodes);

        /** @var DOMElement $shortcode */
            foreach ($shortcodes as $shortcode) {
                $tag = $tags[$shortcode->getAttribute('data-tagid')];
                $parent = $parents[$shortcode->getAttribute('data-parentid')];

                $class = null;
                if (!empty($tag['attrs']['location'])) {
                    $class = $tag['attrs']['location'];
                } elseif (!empty($tag['attrs']['class'])) {
                    $class = $tag['attrs']['class'];
                }

                $location = self::INLINE;
                if ($class == 'left' || $class == 'right') {
                    $location = self::BEFORE;
                }
                /**
                 * Below code disabled due to https://github.com/silverstripe/silverstripe-framework/issues/5987
                if ($class == 'center' || $class == 'leftAlone') {
                    $location = self::SPLIT;
                }
                 */

                if (!$parent) {
                    if ($location !== self::INLINE) {
                        user_error(
                            "Parent block for shortcode couldn't be found, but location wasn't INLINE",
                            E_USER_ERROR
                        );
                    }
                } else {
                    $this->moveMarkerToCompliantHome($shortcode, $parent, $location);
                }

                $this->replaceMarkerWithContent($shortcode, $tag);
            }

            $content = $htmlvalue->getContent();

            // Clean up any marker classes left over, for example, those injected into <script> tags
            $parser = $this;
            $content = preg_replace_callback(
                // Not a general-case parser; assumes that the HTML generated in replaceElementTagsWithMarkers()
                // hasn't been heavily modified
                '/<img[^>]+class="' . preg_quote(self::$marker_class) . '"[^>]+data-tagid="([^"]+)"[^>]*>/i',
                function ($matches) use ($tags, $parser) {
                    $tag = $tags[$matches[1]];
                    return $parser->getShortcodeReplacementText($tag);
                },
                $content
            );
        }

        $this->extend('onAfterParse', $content);

        return $content;
    }
835169
public function getStackTraceFrames(array $trace): array
    {
        return \Raven_Stacktrace::get_stack_info(
            $trace,
            $this->client->trace,
            [],
            $this->client->message_limit,
            $this->client->getPrefixes(),
            $this->client->getAppPath(),
            $this->client->getExcludedAppPaths(),
            $this->serializer,
            $this->reprSerializer
        );
    }
1272176
public function parse($content)
	{
		$log = new Log;
		$description = [];
		$links = [];
		$matches = [];
		$bodyEnded = false;

		$line = current($content);
		while ($line !== false)
		{
			$line = ltrim($line);

			if (preg_match('/^#(?!#).+/', $line) === 1)
			{
				$log->setTitle($this->trimHashes($line));
			}
			elseif (preg_match('/^##(?!#).+/', $line) === 1)
			{
				$release = $this->parseRelease($content);
				$log->addRelease($release);
				$bodyEnded = true;
			}
			elseif (preg_match('/^\[(.+)\]: (.+)/', $line, $matches))
			{
				if (count($matches) >= 3)
				{
					$links[$matches[1]] = $matches[2];
				}
				$bodyEnded = true;
			}
			elseif ( ! $bodyEnded)
			{
				$description[] = $line;
			}

			$line = next($content);
		}

		$log->setDescription(implode("\n", $description));

		// Assign the releases their real links
		$this->assignLinks($log, $links);

		return $log;
	}
572786
protected function parse(/*# string */ $contents)/*# : array */
    {
        $result = [];
        $regex = sprintf(
            '/^\s*+(%s)\s*+=\s*+(%s)(?:#.*+)?\s*$/m',
            $this->name_pattern,
            $this->value_pattern
        );
        if (preg_match_all($regex, $contents, $matched, \PREG_SET_ORDER)) {
            foreach ($matched as $m) {
                $result[$m[1]] = trim($m[2]);
            }
        }
        return $result;
    }
1051268
protected function parseContent($content)
    {
        $content = preg_replace_callback($this->shortcodeRegex(), [$this, 'doShortcodeTag'], $content);
        if (!$this->isFinishedParse()) {
            $content = $this->parseContent($content);
        }
        return $content;
    }
859638
protected function parseJson($content)
    {
        $content = json_decode($content, true);
        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new \UnexpectedValueException(sprintf(
                "JSON 解析失败: %s",
                json_last_error_msg()
            ));
        }

        return $content;
    }
1090428
protected function parseMessageFromRequest($content)
    {
        $content = (string)$content;

        $encryptor = new Encryptor(
            $this->config->get('app_id'),
            $this->config->get('token'),
            $this->config->get('aes_key')
        );

        $message = $encryptor->decryptMsg(
            $this->request->get('msg_signature'),
            $this->request->get('nonce'),
            $this->request->get('timestamp'),
            $content
        );

        return new Collection($message);
    }
1156807
public function parseLang($content) {
        $this->_content = $content;
        $this->_parseDebugStart();
        $this->_parsePath();
        $this->_parseGravatar();
        $this->_parseUrl();
        $this->_parsePhp();
        $this->_parseLang();
        $this->_parseForeach();
        $this->_parseFor();
        $this->_parseVar();
        $this->_parseVarFunc();
        $this->_parseCondition();
        $this->_parseFunction();
        $this->_parseException();
        $this->_parseDebugEnd();

        return $this->_content;
    }
675949
protected function replaceElementTagsWithMarkers($content)
    {
        $tags = $this->extractTags($content);

        if ($tags) {
            $markerClass = self::$marker_class;

            $content = $this->replaceTagsWithText($content, $tags, function ($idx, $tag) use ($markerClass) {
                return '<img class="' . $markerClass . '" data-tagid="' . $idx . '" />';
            });
        }

        return array($content, $tags);
    }
316281
public static function getContentMimeType($content)
    {
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        $mimeType = finfo_buffer($finfo, $content);
        finfo_close($finfo);

        return $mimeType;
    }
393229
protected function parseMessageFromRequest($content)
    {
        $content = strval($content);

        $arrayable = json_decode($content, true);
        if (json_last_error() === JSON_ERROR_NONE) {
            return $arrayable;
        }

        if (!$this->encryptor) {
            throw new RuntimeException('Safe mode Encryptor is necessary, please use Guard::setEncryptor(Encryptor $encryptor) set the encryptor instance.');
        }

        $message = $this->encryptor->decryptMsg(
            $this->request->get('msg_signature'),
            $this->request->get('nonce'),
            $this->request->get('timestamp'),
            $content
        );

        return $message;
    }
986914
public function parse($content)
    {
        $content = $this->normalize($content);

        list($scheme, $code, $message) = $this->getStatus($content);

        $response = new Response();
        $response->setProtocolVersion($scheme);
        $response->setStatus($code, $message);

        list($header, $body) = $this->splitMessage($content);

        $this->headerToArray($response, $header);

        $response->setBody(new StringStream($body));

        return $response;
    }
519006
private function getContentData($content)
    {
        $res = [];
        $res['startStringPos'] = strpos($content, $this->startString) + strlen($this->startString);
        $res['endStringPos'] = strpos($content, $this->endString);
        $res['bundleList'] = substr($content, $res['startStringPos'], ($res['endStringPos'] - $res['startStringPos']));
        return $res;
    }
1226201
public function findAllShortcodeIds( $content ) {
		$ids = [];
		$matches = [];
		$regex = get_shortcode_regex( [ self::SHORTCODE ] );
		if ( preg_match_all( '/' . $regex . '/s', $content, $matches, PREG_SET_ORDER ) ) {
			foreach ( $matches as $shortcode ) {
				$shortcode_attrs = shortcode_parse_atts( $shortcode[3] );
				if ( is_array( $shortcode_attrs ) && isset( $shortcode_attrs['id'] ) ) {
					// Remove quotes, return just the integer
					$my_id = $shortcode_attrs['id'];
					$my_id = trim( $my_id, "'" );
					$my_id = trim( $my_id, '"' );
					$my_id = str_replace( '&quot;', '', $my_id );
					$ids[] = (int) $my_id;
				}
			}
		}
		return $ids;
	}
1350532
protected function _getPaddedLine($content)
    {
        if (!is_array($content)) $content = array( $content );
        if ($this->column_size===0 && $this->line_size===0 && $this->cell_size===0) {
            $this->_parseTableSizes();
        }
        if (count($content) > $this->getColumnSize()) {
            $this->_repadAllLines();
        } elseif (count($content) < $this->getColumnSize() && ($this->getPadFlag() & self::PAD_BY_EMPTY_CELLS)) {
            $content = array_pad($content, $this->getColumnSize(), '');
        }
        return $content;
    }
1020561
public static function findExternalLinks($content)
    {
        $matches = null;
        preg_match_all('/(?:href|src)=\"([^\"]+)/', $content, $matches);

        if (empty($matches[1])) {
            return [];
        }

        return $matches[1];
    }