-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
script: Update name validation for attribute, element, and doctype #37747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
script: Update name validation for attribute, element, and doctype #37747
Conversation
You need to |
🛠 These changes could not be applied onto the latest upstream WPT. Servo's copy of the Web Platform Tests may be out of sync. |
0b3d4c8
to
cbb0407
Compare
Below is a summary of how the current draft performs on a few related WPT test files (the live version)
The test cases that are still failing in Would this draft be considered good enough for review or is it better to wait until it passes all |
d52c0fe
to
e6fa526
Compare
e6fa526
to
34c2623
Compare
@@ -120,9 +123,7 @@ use crate::dom::bindings::str::{DOMString, USVString}; | |||
use crate::dom::bindings::trace::{HashMapTracedValues, NoTrace}; | |||
#[cfg(feature = "webgpu")] | |||
use crate::dom::bindings::weakref::WeakRef; | |||
use crate::dom::bindings::xmlname::{ | |||
matches_name_production, namespace_from_domstring, validate_and_extract, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these methods still being used?
If not, let's remove them. Otherwise we need to somehow unify them with the new methods introduced by this PR.
The main consideration is to avoid maintaining multiple mechanisms for the same thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
matches_name_production
is still being used in two places that still requires XML naming rules (CreateProcessingInstruction
and set_custom_attribute
, which do require XML naming after the spec update see whatwg/dom#1079 and https://html.spec.whatwg.org/multipage/dom.html#custom-data-attribute).
namespace_from_domstring
is just a convenient conversion that's used in many places, but we could also move it into the name_validation
mod.
There remains one usage of xmlname::validate_and_extract
during evaluation of xpath, which I assume that XML naming rules is used. The relevant docs are not well maintained (see https://dom.spec.whatwg.org/#xpath)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears that after this change, usage of xmlname
will be the special case. We need to decide the fate of the exposed functions there:
matches_name_production
is well-scoped by XML and should remain therenamespace_from_domstring
seems still widely used and should be moved to the new filevalidate_and_extract
andvalidate_and_extract_qualified_name
no longer implement the spec, and in the best case should be removed. Could you list out links to all the the renaming usages and let's decide?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3. `validate_and_extract` and `validate_and_extract_qualified_name` no longer implement the spec, and in the best case should be removed. Could you list out links to all the the renaming usages and let's decide?
This is the only remaining usage of the xmlname::validate_and_extract
script::xpath::eval
servo/components/script/xpath/eval.rs
Line 270 in e609017
if let Ok((ns, prefix, local)) = validate_and_extract(namespace, &qname_as_str) { |
validate_and_extract
and validate_and_extract_qualified_name
into this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved validate_and_extract
and validate_and_extract_qualified_name
from script/dom/bindings/xmlname.rs
to script/xpath/eval.rs
and restricted their visibility to private. See commit 73f22a5
34c2623
to
e609017
Compare
@@ -120,9 +123,7 @@ use crate::dom::bindings::str::{DOMString, USVString}; | |||
use crate::dom::bindings::trace::{HashMapTracedValues, NoTrace}; | |||
#[cfg(feature = "webgpu")] | |||
use crate::dom::bindings::weakref::WeakRef; | |||
use crate::dom::bindings::xmlname::{ | |||
matches_name_production, namespace_from_domstring, validate_and_extract, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears that after this change, usage of xmlname
will be the special case. We need to decide the fate of the exposed functions there:
matches_name_production
is well-scoped by XML and should remain therenamespace_from_domstring
seems still widely used and should be moved to the new filevalidate_and_extract
andvalidate_and_extract_qualified_name
no longer implement the spec, and in the best case should be removed. Could you list out links to all the the renaming usages and let's decide?
710e2e7
to
935e866
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Head branch was pushed to by a user without write access
935e866
to
558bd15
Compare
Remember to update PR message as well, which would be the commit message in main. |
Please let me know when this is ready for merging, thanks |
@yezhizhen Do you mind taking a look at the updated PR message? Just trying to see if it's explanatory enough for someone who didn't review the changes? Thanks |
@minghuaw It is very concise and understandable to me. |
Here's the updated WPT test result: https://github.com/minghuaw/servo/actions/runs/16188707259/job/45702433544. @xiaochengh This is ready to get merged |
🛠 These changes could not be applied onto the latest upstream WPT. Servo's copy of the Web Platform Tests may be out of sync. |
Signed-off-by: minghuaw <[email protected]>
Signed-off-by: minghuaw <[email protected]>
Signed-off-by: minghuaw <[email protected]>
Signed-off-by: minghuaw <[email protected]>
Signed-off-by: minghuaw <[email protected]>
Signed-off-by: minghuaw <[email protected]>
Signed-off-by: minghuaw <[email protected]>
Signed-off-by: Minghua Wu <[email protected]>
Signed-off-by: Minghua Wu <[email protected]>
Signed-off-by: Minghua Wu <[email protected]>
Signed-off-by: Minghua Wu <[email protected]>
Co-authored-by: Xiaocheng Hu <[email protected]> Signed-off-by: minghuaw <[email protected]>
Co-authored-by: Xiaocheng Hu <[email protected]> Signed-off-by: minghuaw <[email protected]>
Co-authored-by: Xiaocheng Hu <[email protected]> Signed-off-by: minghuaw <[email protected]>
Signed-off-by: Minghua Wu <[email protected]>
Signed-off-by: Minghua Wu <[email protected]>
Signed-off-by: Minghua Wu <[email protected]>
Signed-off-by: Minghua Wu <[email protected]>
Signed-off-by: Minghua Wu <[email protected]>
Signed-off-by: minghuaw <[email protected]>
Signed-off-by: minghuaw <[email protected]>
Signed-off-by: Minghua Wu <[email protected]>
Signed-off-by: minghuaw <[email protected]>
Signed-off-by: minghuaw <[email protected]>
d6d9d53
to
ebef119
Compare
A recent update in the spec (whatwg/dom#1079) introduced new rules for name validation of attribute, element, and doctype. This PR implements the new name validation rules in
components/script/dom/bindings/domname.rs
. The old XML name validation rules are not fully removed because there remains a few usage of it inProcessingInstructions
andxpath
.Testing: Covered by WPT tests
Fixes: #37746