Fix #16: TitleCharacterRule um Punkt, Komma und Ampersand erweitern

- Erweitere TitleCharacterRule.isAllowed() um die Zeichen: . (Punkt), , (Komma), & (Ampersand)
- Passe JavaDoc-Kommentare auf Deutsch an
- Aktualisiere TitleCharacterRuleTest: ändere Punkt-Test von disallowed zu allowed
- Füge Tests für Komma und Ampersand hinzu
- Füge Tests hinzu, die Windows-Sonderzeichen (\ / : * ? " < > |) weiterhin als ungültig bestätigen
- Aktualisiere TargetFilenameBuildingServiceTest für den neuen Test-Fall
- Dokumentation: fachliche-anforderungen.md und CLAUDE.md aktualisiert

mvn clean verify erfolgreich bestanden

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-04-23 17:07:07 +02:00
parent 1df541d0f9
commit c46294159c
5 changed files with 67 additions and 26 deletions
@@ -1,15 +1,15 @@
package de.gecheckt.pdf.umbenenner.application.service;
/**
* Canonical rule for allowed title characters.
* Kanonische Regel für erlaubte Titelzeichen.
* <p>
* A title may contain only Unicode letters (including German Umlauts and ß),
* decimal digits, ASCII spaces, and hyphens ({@code -}).
* All other characters are considered disallowed.
* Ein Titel darf nur Unicode-Buchstaben (einschließlich deutscher Umlaute und ß),
* Ziffern, ASCII-Leerzeichen, Bindestriche ({@code -}), Punkte ({@code .}),
* Kommas ({@code ,}) und Ampersands ({@code &}) enthalten.
* Alle anderen Zeichen sind nicht erlaubt.
* <p>
* This class is the single authoritative implementation of the character-allowlist
* rule. All services that need to validate or verify title characters must delegate
* to {@link #isAllowed(String)} instead of maintaining their own copies.
* Diese Klasse ist die einzige autoritative Implementierung der Zeichenerlaubnis-Regel.
* Alle Services, die Titelzeichen validieren müssen, delegieren an {@link #isAllowed(String)}.
*/
public final class TitleCharacterRule {
@@ -18,20 +18,23 @@ public final class TitleCharacterRule {
}
/**
* Returns {@code true} if every character in {@code title} is a letter, digit,
* ASCII space, or hyphen ({@code -}).
* Gibt {@code true} zurück, wenn jedes Zeichen im {@code title} ein Buchstabe, eine Ziffer,
* ein ASCII-Leerzeichen, ein Bindestrich ({@code -}), ein Punkt ({@code .}),
* ein Komma ({@code ,}) oder ein Ampersand ({@code &}) ist.
* <p>
* Unicode letters — including German Umlauts (ä, ö, ü, Ä, Ö, Ü) and ß — are
* permitted. An empty string is considered allowed.
* Unicode-Buchstabeneinschließlich deutscher Umlaute (ä, ö, ü, Ä, Ö, Ü) und ß — sind
* erlaubt. Eine leere Zeichenkette ist erlaubt.
*
* @param title the title to check; must not be null
* @return {@code true} if all characters pass the allowlist; {@code false} otherwise
* @throws NullPointerException if {@code title} is null
* @param title der zu prüfende Titel; darf nicht null sein
* @return {@code true} wenn alle Zeichen die Erlaubnisliste erfüllen; {@code false} andernfalls
* @throws NullPointerException wenn {@code title} null ist
*/
public static boolean isAllowed(String title) {
for (int i = 0; i < title.length(); i++) {
char c = title.charAt(i);
if (!Character.isLetter(c) && !Character.isDigit(c) && c != ' ' && c != '-') {
// Erlaubt: Buchstaben, Ziffern, Leerzeichen, Bindestrich, Punkt, Komma, Ampersand
if (!Character.isLetter(c) && !Character.isDigit(c) && c != ' ' && c != '-'
&& c != '.' && c != ',' && c != '&') {
return false;
}
}