Page MenuHomePhabricator

0001-Parser-Fix-the-main-loop-getting-stuck-on-some-signa.patch

Authored By
matmarex
Feb 7 2024, 6:39 PM
Size
1 KB
Referenced Files
None
Subscribers
None

0001-Parser-Fix-the-main-loop-getting-stuck-on-some-signa.patch

From 674339e96522c5bc8b6d58eb3ee5c1dfc35f8a8d Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Bartosz=20Dziewo=C5=84ski?= <dziewonski@fastmail.fm>
Date: Wed, 7 Feb 2024 17:42:04 +0100
Subject: [PATCH] Parser: Fix the main loop getting stuck on some signatures
In certain cases the parser could go back rather than forward after
finding a signature, causing it to find the same signature forever
until it ran out of memory.
Bug: T356884
Change-Id: I8ac72b05e5e4ed45e6119c012a69708c9d8eda29
---
includes/CommentParser.php | 2 +-
modules/Parser.js | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/includes/CommentParser.php b/includes/CommentParser.php
index 4a511ec2..f37abd96 100644
--- a/includes/CommentParser.php
+++ b/includes/CommentParser.php
@@ -922,7 +922,7 @@ class CommentParser {
$curCommentEnd = $node;
} elseif ( $node instanceof Text && ( $match = $this->findTimestamp( $node, $timestampRegexps ) ) ) {
$warnings = [];
- $foundSignature = $this->findSignature( $node, $lastSigNode );
+ $foundSignature = $this->findSignature( $node, $curCommentEnd === $this->rootNode ? null : $curCommentEnd );
$author = $foundSignature['username'];
$lastSigNode = $foundSignature['nodes'][0];
diff --git a/modules/Parser.js b/modules/Parser.js
index 7b653061..07c1f43a 100644
--- a/modules/Parser.js
+++ b/modules/Parser.js
@@ -895,7 +895,7 @@ Parser.prototype.buildThreadItems = function () {
curCommentEnd = node;
} else if ( node.nodeType === Node.TEXT_NODE && ( match = this.findTimestamp( node, timestampRegexps ) ) ) {
var warnings = [];
- var foundSignature = this.findSignature( node, lastSigNode );
+ var foundSignature = this.findSignature( node, curCommentEnd === this.rootNode ? null : curCommentEnd );
var author = foundSignature.username;
lastSigNode = foundSignature.nodes[ 0 ];
--
2.28.0.windows.1

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14551760
Default Alt Text
0001-Parser-Fix-the-main-loop-getting-stuck-on-some-signa.patch (1 KB)

Event Timeline