Skip to content

Makes removal of leading and trailing space optional when domain name is normalized#1260

Merged
matsduf merged 2 commits into
zonemaster:developfrom
matsduf:update-requirement-normalization-doc
Jun 2, 2025
Merged

Makes removal of leading and trailing space optional when domain name is normalized#1260
matsduf merged 2 commits into
zonemaster:developfrom
matsduf:update-requirement-normalization-doc

Conversation

@matsduf

@matsduf matsduf commented Apr 30, 2024

Copy link
Copy Markdown
Contributor

Purpose

In current version of "Requirements and normalization of domain names in input" leading and trailing space characters are to be removed from domain names in all contexts. Issue zonemaster/zonemaster-cli#364 sees it as a problem that a domain name that has been entered within quote marks on a command line should have leading and trailing space removed.

The reporter, however, wants to keep the current behavior when domain names are entered in an HTML form.

This PR make removal of leading and trailing space optional and depending on context, which makes it less predictable what behavior is to be applied. If such space characters are not removed, the domain name will be classified as illegal and no testing will be performed.

It is not obvious that the change in this PR will give any benefits. Also, the specification will be less precise. It will, however, only affect some marginal cases or cases where white space characters have been included by mistake.

Context

Changes

"Requirements and normalization of domain names in input" is updated. If this PR is merged then zonemaster/zonemaster-engine#1316 can be merged.

How to test this PR

Review.

@matsduf matsduf added the A-Documentation Area: Documentation only. label Apr 30, 2024
@matsduf matsduf added this to the v2024.1 milestone Apr 30, 2024
@marc-vanderwal

marc-vanderwal commented May 2, 2024

Copy link
Copy Markdown
Contributor

If there is any whitespace in the illegal domain name, we could also add a message to the user suggesting to run the test on the domain name with all whitespace stripped. Something like:

The domain name example .com contains characters that cannot appear in domain names. Did you mean to test example.com?

The same could be done when the user input looks like an HTTP URL, because looking through zonemaster.net’s logs shows many attempts at testing domain names such as https://example.com. That could look like:

The domain name https://example.com contains illegal characters that cannot appear in domain names. Did you mean to test example.com?

In all other cases, we don’t suggest anything.

How about going that route instead? It can be implemented consistently in CLI and GUI, becomes an opportunity to educate the user about the difference between a domain name and a URL, and also avoids “trying to be smarter” than the user by attempting to automatically fix their mistakes.

(Edit: urgh, even stupid Github seems to try to outsmart me by stripping spaces after ` characters in the Markdown syntax. What a funny coincidence!)

@matsduf

matsduf commented May 2, 2024

Copy link
Copy Markdown
Contributor Author

If there is any whitespace in the illegal domain name, we could also add a message to the user suggesting to run the test on the domain name with all whitespace stripped. Something like:

The domain name example .com contains characters that cannot appear in domain names. Did you mean to test example.com?

Is that something to be implemented in GUI? Or do you suggest an update to this specification?

The same could be done when the user input looks like an HTTP URL, because looking through zonemaster.net’s logs shows many attempts at testing domain names such as https://example.com. That could look like:

The domain name https://example.com contains illegal characters that cannot appear in domain names. Did you mean to test example.com?

Is that something to be implemented in GUI? Or do you suggest an update to this specification?

In all other cases, we don’t suggest anything.

If the domain name is not delegated, Basic02 strips off one label and creates a message where the user is suggested to test the superdomain of the domain name.

How about going that route instead? It can be implemented consistently in CLI and GUI, becomes an opportunity to educate the user about the difference between a domain name and a URL, and also avoids “trying to be smarter” than the user by attempting to automatically fix their mistakes.

What is your suggestion? Starting to suggest things in messages?

@mattias-p

Copy link
Copy Markdown
Member

After our discussion in the work group meeting I started thinking about this in a pure Zonemaster GUI context. I had a quick look and counted four types of text fields in our UI: domain name, IP address, keytag and digest. If we think the trimming of surrounding space is important enough that we need to specify how it is done, we should specify it for text fields of all types, not only domain names. We could specify it for each type individually like it is done here for domain names, but I don't feel this is the most reasonable approach. A better approach, IMHO, would be to have a separate specification of how surrounding space is trimmed and apply that to all text fields in Zonemaster GUI as a preprocessing step before any validation is done.

@matsduf

matsduf commented May 3, 2024

Copy link
Copy Markdown
Contributor Author

It is true that trimming of leading and trailing white space should be done in all fields in GUI.

@matsduf

matsduf commented May 3, 2024

Copy link
Copy Markdown
Contributor Author

In GUI, if IP address, key ID or digest has white space an error is issued. I think that is done in Backend, isn't it? I think trimming would be more helpful. (Algorithm and digest type are drop down lists.)

mattias-p
mattias-p previously approved these changes May 27, 2025

@mattias-p mattias-p left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be enough to go forward with zonemaster/zonemaster-engine#1316, right?

@mattias-p

Copy link
Copy Markdown
Member

In GUI, if IP address, key ID or digest has white space an error is issued. I think that is done in Backend, isn't it? I think trimming would be more helpful. (Algorithm and digest type are drop down lists.)

If we specify trimming in the Backend API we'd have to add trimming rules for every data type in the Backend API that happens to use a text field for input in the GUI. If we switch the input widgets for a field in the GUI, we'd have to update the Backend API as well to adapt to the normalization characteristics of the new widget. IMHO it's better to separate concerns and deal with GUI stuff in GUI.

But for the purpose of zonemaster/zonemaster-engine#1316 this PR should be good enough, and it would be nice to be done with that one in time for the release.

Comment thread docs/public/specifications/tests/RequirementsAndNormalizationOfDomainNames.md Outdated
Co-authored-by: Marc van der Wal <103426270+marc-vanderwal@users.noreply.github.com>
@matsduf

matsduf commented May 28, 2025

Copy link
Copy Markdown
Contributor Author

If we specify trimming in the Backend API we'd have to add trimming rules for every data type in the Backend API that happens to use a text field for input in the GUI. If we switch the input widgets for a field in the GUI, we'd have to update the Backend API as well to adapt to the normalization characteristics of the new widget. IMHO it's better to separate concerns and deal with GUI stuff in GUI.

I am not sure what you mean, but we should both make sure that we do not get garbage into the system and that users do not get error messages on trivial deviations if field content, i.e. where it is obvious what the users want.

Domain names are special and complex, as the document shows, but we could other elements to it such as IP addresses.

Another example is digest for DS. Bind often shows it two parts, but the space should be ignored. If you enter the digest in that way Zonemaster will complain. Maybe Zonemaster could be helpful, but should probably be up to GUI to do.

@matsduf matsduf merged commit 10d9c62 into zonemaster:develop Jun 2, 2025
@matsduf matsduf deleted the update-requirement-normalization-doc branch June 2, 2025 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Documentation Area: Documentation only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Separate handling of surrounding space from normalization in specification

5 participants