Windows-Zeichenbereinigung im Basis-Dateinamen wirksam gemacht und Tests

korrigiert
This commit is contained in:
2026-04-07 14:18:18 +02:00
parent 7e4201b651
commit df0a3ad07b
2 changed files with 37 additions and 16 deletions
@@ -91,16 +91,16 @@ public final class TargetFilenameBuildingService {
* <ul>
* <li>Resolved date must be non-null.</li>
* <li>Validated title must be non-null and non-blank.</li>
* <li>Validated title must not exceed 20 characters.</li>
* <li>Validated title must contain only letters, digits, and spaces.</li>
* <li>Validated title must not exceed 20 characters (before Windows cleaning).</li>
* <li>After Windows-character cleaning, title must contain only letters, digits, and spaces.</li>
* </ul>
* If any rule is violated, the state is treated as an
* {@link InconsistentProposalState}.
* <p>
* Windows compatibility: The final filename is cleaned of Windows-incompatible characters
* (e.g., {@code < > : " / \ | ? *}) to ensure the resulting filename can be created on
* Windows systems. This is a defensive measure; the validated title is already expected
* to contain only letters, digits, and spaces.
* Windows compatibility: Windows-incompatible characters
* (e.g., {@code < > : " / \ | ? *}) are removed from the title before final validation.
* This ensures the resulting filename can be created on Windows systems.
* The 20-character rule is applied to the original title before cleaning.
* <p>
* The 20-character limit applies exclusively to the base title. A duplicate-avoidance
* suffix (e.g., {@code (1)}) may be appended by the target folder adapter after this
@@ -132,21 +132,23 @@ public final class TargetFilenameBuildingService {
+ title + "'");
}
if (!isAllowedTitleCharacters(title)) {
return new InconsistentProposalState(
"Leading PROPOSAL_READY attempt has title with disallowed characters "
+ "(only letters, digits, and spaces are permitted): '"
+ title + "'");
}
// Defensive Windows compatibility: remove Windows-incompatible characters
// Remove Windows-incompatible characters to enable technical Windows compatibility
String cleanedTitle = removeWindowsIncompatibleCharacters(title);
if (cleanedTitle.isBlank()) {
return new InconsistentProposalState(
"Title becomes empty after Windows-compatibility cleaning: '"
+ title + "'");
}
// After cleaning, verify that only letters, digits, and spaces remain
if (!isAllowedTitleCharacters(cleanedTitle)) {
return new InconsistentProposalState(
"After Windows-compatibility cleaning, title contains disallowed characters "
+ "(only letters, digits, and spaces are permitted): '"
+ cleanedTitle + "'");
}
// Build: YYYY-MM-DD - Titel.pdf
String baseFilename = date + " - " + cleanedTitle + ".pdf";
return new BaseFilenameReady(baseFilename);