Repository navigation
Conversation
This was referenced Sep 26, 2026
Closed
tobocop2
marked this pull request as ready for review
September 27, 2026 03:38
Goldziher
force-pushed
the
fix/one-raw-text-definition
branch
from
September 27, 2026 08:51
49db81e to
8c4ab0c
Compare
…kdown Link extraction masked raw text with a hand-written scanner that knew four elements, while the markdown path used an html5ever-based scan. They disagreed: link extraction read links inside xmp, iframe, noembed, noframes and plaintext, treated <script/> as closed, read script inside svg foreignObject as markup, let a quote inside an unquoted attribute value open a quote, and a "<!--" inside the newly covered elements hid every later link. The masking is now built on the html5ever tree builder, with scripting off for link extraction (noscript content is markup) and on for markdown. The masked text keeps its byte length, so every caller's offsets hold. The first real <base href> now comes from the same scan for both paths. On a dense 1 MB page the masking takes about 17 ms, against 1.5 ms for the old scanner; on a typical 1 MB page 3.3 ms against 1.6 ms.
Nothing checked that </titles> does not close a <title>; a test now covers <title> and <style>. The changelog also names every foreign-content exception the masking follows: svg foreignObject, desc and title, and the MathML text integration points and annotation-xml.
Goldziher
force-pushed
the
fix/one-raw-text-definition
branch
from
September 27, 2026 08:53
8c4ab0c to
12370cc
Compare
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #123. Merge that first, then retarget this to main.
One definition of raw text
Link extraction and the markdown pre-pass decided differently what counts as raw text. Link extraction used a hand-written scanner that knew
script,style,titleandtextarea; the markdown path used an html5ever scan. Both now use one masking pass built on the html5ever tree builder, so they read a page the way a browser does.What link extraction now leaves alone
Links inside
xmp,iframe,noembed,noframesandplaintext; the content after<script/>; a script inside SVGforeignObject. A quote inside an unquoted attribute value no longer opens a quote, and a<!--inside any raw-text element no longer hides the links after it.noscriptcontent counts as markup for link extraction (a crawler does not run script) and as text for markdown, which matches the converter.Base address
The first real
<base href>now comes from the same scan, for both link extraction and markdown, so a<base>written inside raw text no longer redirects every link.Cost
The masked text keeps its byte length and is byte-identical to before on four real pages. On a dense 1 MB page the masking takes about 17 ms against 1.5 ms before; on a typical 1 MB page 3.3 ms against 1.6 ms.
Closes #201