Repository navigation
Commit 48aba8c
fix(sax-parser): enter and leave foreign namespaces where tree construction does
Tree construction pops a self-closing `svg` or `math` element at once, but the feedback simulator kept its namespace frame, so the content after `<svg/>` was tokenized as foreign (a CDATA section became text instead of a bogus comment) and a stream of self-closing roots grew the namespace stack without bound. The end tag of an `annotation-xml` integration point never left its HTML frame either, because the check looked for the `encoding` attribute on an end tag, while a stray end tag of another integration point (`</mo>` inside `mi`) or the end tag of a nested HTML element of the same name (`<mi></mi>` inside `mi`) left a frame that tree construction keeps.
The simulator also opened a frame for every `svg` or `math` start tag, while in foreign content tree construction inserts them as elements of the current namespace and only `svg` in `annotation-xml` opens SVG content, so in `<math><svg><desc>` the `desc` became an HTML integration point and a CDATA section in it a bogus comment. `mglyph` and `malignmark` in a MathML text integration point stay MathML elements, where the simulator kept HTML content. The `</p>` and `</br>` end tags break out of foreign content as `<p>` and `<br>` do, where the simulator stayed in it, and a breakout pops every foreign element up to an HTML element or integration point, where the simulator left only one frame.
Each frame now remembers the name of the tag that opened it: an HTML element of that name inside the frame opens a frame of its own, and an end tag closes the frame only when it is that tag's. The simulator also knows whether the current node is the element that opened the last frame and whether each frame's element is the parent of the next. An `svg` or `math` start tag in foreign content opens a frame of its own namespace, and one of the other namespace only while the current node is not known: it may be `annotation-xml`, or the tree may already have left the frame. `mglyph` and `malignmark` open a MathML frame directly in a text integration point, and the end tag of that element or of the frame's below closes it too. A self-closing element ends the frame it opened at once, and a breakout leaves all foreign frames.
Where one wrong frame cancelled another gap of the simulator, the input now shows that gap: an HTML ancestor's end tag (`<div><svg><math><ms></div>`), an HTML element still open at an integration point's end tag (`<math><mo><svg></p><desc></mo>`), a stray `</math>` inside an integration point, and tags that `select` ignores.
The tests cover self-closing svg, math, repeated roots and svg inside math; MathML content after an annotation-xml end tag, in desc inside svg inside math and in mglyph inside mi; stray end tags inside mi and annotation-xml frames, the end tag of an annotation-xml nested inside one, and `</p>` in svg inside mi.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>1 parent f52fa37 commit 48aba8c
2 files changed
Lines changed: 141 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
21 | 28 | | |
22 | 29 | | |
23 | 30 | | |
| |||
27 | 34 | | |
28 | 35 | | |
29 | 36 | | |
30 | | - | |
| 37 | + | |
31 | 38 | | |
32 | 39 | | |
33 | 40 | | |
| |||
85 | 92 | | |
86 | 93 | | |
87 | 94 | | |
88 | | - | |
| 95 | + | |
89 | 96 | | |
| 97 | + | |
| 98 | + | |
90 | 99 | | |
91 | 100 | | |
92 | 101 | | |
93 | 102 | | |
94 | 103 | | |
95 | 104 | | |
| 105 | + | |
| 106 | + | |
96 | 107 | | |
97 | 108 | | |
98 | 109 | | |
| |||
130 | 141 | | |
131 | 142 | | |
132 | 143 | | |
| 144 | + | |
| 145 | + | |
133 | 146 | | |
134 | 147 | | |
135 | | - | |
136 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
137 | 160 | | |
138 | 161 | | |
139 | | - | |
140 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
141 | 177 | | |
142 | 178 | | |
143 | 179 | | |
| |||
146 | 182 | | |
147 | 183 | | |
148 | 184 | | |
149 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
150 | 188 | | |
| 189 | + | |
151 | 190 | | |
152 | 191 | | |
153 | 192 | | |
| |||
161 | 200 | | |
162 | 201 | | |
163 | 202 | | |
164 | | - | |
165 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
166 | 210 | | |
167 | 211 | | |
168 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
169 | 220 | | |
170 | 221 | | |
171 | 222 | | |
| |||
185 | 236 | | |
186 | 237 | | |
187 | 238 | | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
188 | 244 | | |
189 | 245 | | |
190 | 246 | | |
191 | 247 | | |
192 | 248 | | |
193 | | - | |
| 249 | + | |
| 250 | + | |
194 | 251 | | |
195 | 252 | | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
205 | 258 | | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
206 | 268 | | |
207 | | - | |
208 | | - | |
209 | | - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
210 | 275 | | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | 276 | | |
217 | 277 | | |
218 | 278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
226 | 280 | | |
227 | 281 | | |
228 | 282 | | |
| |||
0 commit comments