Skip to content

Commit 8b796c7

Browse files
committed
Revert "Merge pull request #19373 from Yoast/PC-1029-anchors-containing-square-brackets-in-content-lead-to-errors-with-classic-editor"
This reverts commit 69006b0, reversing changes made to 89a5291.
1 parent 27f072a commit 8b796c7

2 files changed

Lines changed: 3 additions & 32 deletions

File tree

packages/yoastseo/spec/languageProcessing/helpers/word/markWordsInSentenceSpec.js

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -168,34 +168,4 @@ describe( "test the deconstructAnchor and reconstructAnchor helper", () => {
168168
const reconstructedAnchor = reConstructAnchor( deconstructedAnchor.openTag, deconstructedAnchor.content );
169169
expect( reconstructedAnchor ).toEqual( testAnchor );
170170
} );
171-
172-
it( "correctly deconstructs and reconstructs an anchor if does not contain content", () => {
173-
// Unrealistic Scenario. But protects against the bug that is solved in this PR:
174-
// https://github.com/Yoast/wordpress-seo/pull/19373
175-
const testAnchor = "<a href=\"https://yoast.com\"></a>";
176-
const deconstructedAnchor = deConstructAnchor( testAnchor );
177-
178-
expect( deconstructedAnchor ).toEqual( {
179-
openTag: "<a href=\"https://yoast.com\">",
180-
content: "",
181-
} );
182-
183-
const reconstructedAnchor = reConstructAnchor( deconstructedAnchor.openTag, deconstructedAnchor.content );
184-
expect( reconstructedAnchor ).toEqual( testAnchor );
185-
} );
186-
187-
it( "correctly deconstructs and reconstructs an anchor if content contains a newline", () => {
188-
// Unrealistic Scenario. But protects against the bug that is solved in this PR:
189-
// https://github.com/Yoast/wordpress-seo/pull/19373
190-
const testAnchor = "<a href=\"https://yoast.com\">This is a line.\nAnd this is a line.</a>";
191-
const deconstructedAnchor = deConstructAnchor( testAnchor );
192-
193-
expect( deconstructedAnchor ).toEqual( {
194-
openTag: "<a href=\"https://yoast.com\">",
195-
content: "This is a line.\nAnd this is a line.",
196-
} );
197-
198-
const reconstructedAnchor = reConstructAnchor( deconstructedAnchor.openTag, deconstructedAnchor.content );
199-
expect( reconstructedAnchor ).toEqual( testAnchor );
200-
} );
201171
} );

packages/yoastseo/src/languageProcessing/helpers/word/markWordsInSentences.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import matchWords from "../match/matchTextWithArray";
66
import arrayToRegex from "../regex/createRegexFromArray";
77

88
// Regex to deconstruct an anchor into open tag, content and close tag.
9-
// [^] matches any character, including newline
10-
const anchorDeconstructionRegex = /(<a[\s]+[^>]+>)([^]*?)(<\/a>)/;
9+
const anchorDeconstructionRegex = /(<a[\s]+[^>]+>)(.+?)(<\/a>)/;
1110

1211
/**
1312
* Deconstructs an anchor to the opening tag and the content. The content is the anchor text.
@@ -61,6 +60,7 @@ const getMarkedAnchors = function( sentence, wordsRegex ) {
6160
// Create a new anchor tag with a (marked) anchor text.
6261
return reConstructAnchor( openTag, markedAnchorText );
6362
} );
63+
6464
return { anchors, markedAnchors };
6565
};
6666

@@ -123,6 +123,7 @@ export function markWordsInSentences( wordsToMark, sentences, locale, matchWordC
123123

124124
sentences.forEach( function( sentence ) {
125125
wordsFoundInSentence = matchWords( sentence, wordsToMark, locale, matchWordCustomHelper ).matches;
126+
126127
if ( wordsFoundInSentence.length > 0 ) {
127128
markings = markings.concat( new Mark( {
128129
original: sentence,

0 commit comments

Comments
 (0)