Commit 3367b39
Refuse a duplicate id at register_id under the shadow (#356)
One finding from the review of the shadow path.
`register_id` raises "duplicated id." on the raw path when the id value it
is asked to register is already registered for another attribute, and
under the shadow it silently recorded the spec instead: the replay's
first-wins rule then skipped it, so the call succeeded while the caller's
`#id` reference resolved to whichever element claimed the value first —
an earlier registration, a DTD-declared id attribute or an xml:id.
The check is back at the call that makes the registration, where the fast
path has it, rather than at the replay: raising from a later sign/verify
would report the collision from the wrong call and then from every later
call on that document. `xmlGetID(doc, value) != attr` is assembled from
the two places a registration can live under the shadow — what lxml's own
parse declared, read back through XPath's id(), which crosses the library
boundary as strings and elements only, and what earlier register_id or
add_ids calls recorded in the registry. Re-registering the same attribute
stays the no-op the fast path performs, and add_ids keeps xmlSecAddIDs'
own first-wins semantics, which never raise.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent 7e279cf commit 3367b39
5 files changed
Lines changed: 343 additions & 86 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
204 | | - | |
| 204 | + | |
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
222 | 235 | | |
223 | 236 | | |
224 | 237 | | |
| |||
246 | 259 | | |
247 | 260 | | |
248 | 261 | | |
249 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
250 | 267 | | |
251 | 268 | | |
252 | 269 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | 122 | | |
167 | 123 | | |
168 | 124 | | |
| |||
191 | 147 | | |
192 | 148 | | |
193 | 149 | | |
194 | | - | |
195 | | - | |
196 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
197 | 153 | | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
| 154 | + | |
225 | 155 | | |
226 | 156 | | |
227 | 157 | | |
| |||
0 commit comments