Skip to content

Validate vote service site names - #1540

Merged
BenCodez merged 22 commits into
masterfrom
agent/validate-service-site-names
Aug 5, 2026
Merged

Validate vote service site names#1540
BenCodez merged 22 commits into
masterfrom
agent/validate-service-site-names

Conversation

@BenCodez

@BenCodez BenCodez commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • add a shared validator for external service-site names
  • accept ordinary names, Unicode, domains, and complete URLs with query strings and fragments
  • reject square brackets, ASCII quotes, backticks, backslashes, and invisible or control characters
  • apply validation to standalone, proxy, backend-wire, and automatic-site creation paths
  • report rejected site creation to GUI, command, listener, and manager callers without breaking the existing public method signature
  • add unit and manager-level coverage

Why

Service-site names are used in matching, storage, logging, and generated configuration paths. A targeted validation rule prevents malformed entries without rejecting legitimate service names or URLs already used by vote sources. Explicit generation results prevent callers from reporting success or opening an editor when no site was created.

Accepted format

Non-blank service-site names up to 2,048 characters. Normal URL punctuation is supported, including :, /, ?, =, &, %, +, and #. For example: https://list.example/vote?id=1&source=proxy#top.

Square brackets, single and double ASCII quotes, backticks, backslashes, and invisible/control characters are rejected.

Validation

  • parsed all changed Java sources successfully
  • added focused JUnit coverage for full URLs, URL-encoded values, Unicode names, rejected delimiters, controls, length bounds, and generation failure propagation
  • full Maven validation will run in GitHub Actions because the local environment does not include Maven or a Java 21 compiler

@BenCodez
BenCodez marked this pull request as ready for review August 5, 2026 22:24

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b580931295

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

public final class ServiceSiteValidator {
private static final int MAX_LENGTH = 128;
private static final Pattern VALID_SERVICE_SITE = Pattern
.compile("[A-Za-z0-9][A-Za-z0-9 ._:/-]{0," + (MAX_LENGTH - 1) + "}");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Allow configured punctuation in service-site names

When an existing VoteSites.yml entry uses a service name such as Site's or https://list.example/vote?id=1, this whitelist causes the standalone, proxy, and backend handlers to reject the vote before the configured exact-match lookup, so every vote and reward for that site is lost after upgrading. ConfigVoteSites#setServiceSite still accepts arbitrary strings and no migration or configuration warning is provided; validate only control/path-dangerous input or apply the restrictive rules solely when deriving generated configuration keys.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dca3e77573

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +52 to +55
if (!ServiceSiteValidator.isValid(siteName)) {
plugin.getLogger().warning("Unable to generate vote site with unsupported name '"
+ ServiceSiteValidator.sanitizeForLog(siteName) + "'");
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Report rejected site creation to callers

When an administrator enters a rejected name through the middle-click VoteSites creation GUI, this silent return leaves AdminGUI.onInput believing creation succeeded: it reports "Generated site", reloads, then passes the resulting null site to openAdminGUIVoteSiteSite, which immediately dereferences it and throws. Return a success result or make the GUI validate the name before continuing so rejected input produces an error instead of a broken GUI action.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b435fb7e20

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +69 to +71
int type = Character.getType(codePoint);
return type == Character.CONTROL || type == Character.FORMAT || type == Character.LINE_SEPARATOR
|| type == Character.PARAGRAPH_SEPARATOR || type == Character.SURROGATE;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject non-breaking whitespace-only service names

Reject Unicode space separators that String.isBlank() does not recognize, such as U+00A0, U+2007, and U+202F. A Votifier service name consisting solely of one of these characters currently passes validation, and automatic site creation also leaves it unchanged because the normalization regex uses default \s; this creates an effectively invisible VoteSites key instead of rejecting the malformed name.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ac7959c0fd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +31 to +32
if (!Character.isWhitespace(codePoint) && !Character.isSpaceChar(codePoint)) {
hasVisibleCharacter = true;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject variation-selector-only service names

A service name consisting solely of U+FE0F (VARIATION SELECTOR-16), or U+034F (COMBINING GRAPHEME JOINER), reaches this branch because these code points are neither whitespace nor space characters; Java classifies them as non-spacing marks, so isDisallowed also permits them. The validator consequently accepts an effectively invisible name and automatic creation writes an invisible VoteSites key. Reject default-ignorable code points or require at least one actual base/rendering character.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dcbf1e9e90

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +84 to +85
return type != Character.NON_SPACING_MARK && type != Character.COMBINING_SPACING_MARK
&& type != Character.ENCLOSING_MARK;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject default-ignorable filler letters

When the service name consists only of U+3164 HANGUL FILLER, Java classifies it as OTHER_LETTER, not whitespace or a combining mark, so this method treats it as visible and automatic site creation writes an effectively invisible VoteSites key. Fresh evidence beyond the earlier variation-selector report is that default-ignorable letters such as U+3164, U+115F, and U+1160 remain accepted; reject default-ignorable code points or explicitly require a genuinely rendered character.

Useful? React with 👍 / 👎.

@BenCodez
BenCodez merged commit 5905b4a into master Aug 5, 2026
4 checks passed
@BenCodez
BenCodez deleted the agent/validate-service-site-names branch August 5, 2026 23:10
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.

1 participant