Skip to content
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

Issue 52060: Do trimming of domain names earlier in the process so validation catches reserved words #6319

Open
wants to merge 20 commits into
base: develop
Choose a base branch
from

Conversation

labkey-susanh
Copy link
Contributor

Rationale

Issue 52060 - LKSM: Spaces at the end of source type names are problematic

Related Pull Requests

Changes

  • Trim domain names before validation happens
  • Update error messaging about reserved domain names to be consistent in the different code paths.

@labkey-susanh labkey-susanh requested a review from XingY February 14, 2025 16:48

if (domain.getName() != null)
{
String domainNameError = validateDomainName(domain.getName(), kind.getKindName(), kind.supportsNamingPattern());
String domainNameError = validateDomainName(StringUtils.trimToEmpty(domain.getName()), kind.getKindName(), kind.supportsNamingPattern());
Copy link
Contributor

Choose a reason for hiding this comment

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

I always find this createDomain interface odd, in that the domain can already have name, but then an explicit but optional domainName is passed in. If the domain itself's name contains leading/trailing whitespace, but domainName is null, then the space is saved. Perhaps we should be another domain.setName(StringUtils.trimToNull(domain.getName)) here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in both cases to use trimToEmpty.

@@ -767,7 +767,7 @@ public static ValidationException updateDomainDescriptor(GWTDomain<? extends GWT
return validationException;
}

String updatedName = update.getName();
String updatedName = StringUtils.trimToEmpty(update.getName());
Copy link
Contributor

Choose a reason for hiding this comment

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

This change could be a little problematic. For legacy domains with names that contains illegal characters or patterns, we do still allow them to be updated as long as there is no domain name change. Now if the legacy domain name happened to have leading/trialing white space and also illegal pattern, then this domain can no longer be updated without having to be renamed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I can see that. Since it seems unlikely that the untrimmed name will exist in any case and there is a workaround, I'm leaning toward leaving in this change, though so we'll have less chance of having untrimmed names saved. If anyone sees this as overly problematic, though, I can probably be convinced otherwise.

@cnathe Thoughts on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After further testing, I've moved this trim inside the if (in both cases).


if (original.getName() != null && update.getName() != null && !original.getName().equals(update.getName()))
String trimmedName = StringUtils.trimToNull(update.getName());
if (original.getName() != null && trimmedName != null && !original.getName().equals(trimmedName))
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above regarding legacy domain name support.

@XingY
Copy link
Contributor

XingY commented Feb 17, 2025

Should the component version be bumped to bring the space warning to lks?

@labkey-susanh
Copy link
Contributor Author

Should the component version be bumped to bring the space warning to lks?
good thought. I'll do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants