Page MenuHomePhabricator

Add basic validation and normalization for autonames (S)
Closed, ResolvedPublic

Description

Context

We currently working on some code that's generating names for reused references in VE automatically. With the new code the names will come from potentially random user input. Therefore we should make sure that some basic rules apply to what can be part of these names and what should be stripped / normalized.

Task

Add the following rules to normalize the output of the auto generation:

  • Remove leading and trailing whitespaces
  • Normalize multiple whitespaces to only one simple space
  • Remove or replace all of the following characters: < > “ ’ / \ =
  • Only whitespace or empty string → fallback

Only numbers → prefix with “:”

  • Tests
Normalization / Fallback strategy increment 1
  • Is citation type?
    • Yes: Has override?
      • Yes: Use Citation title override and normalize -> If empty after normalization, fallback to next line
      • No: Use Citation title default and normalize -> If empty after normalization, fallback to next line
    • No: Is there a override for the default title?
      • Yes: Use default title override and normalize -> If empty after normalization, fallback to next line
      • No: Use default title and normalize -> If empty after normalization, fallback to next line
  • Use : as prefix

Event Timeline

lilients_WMDE renamed this task from Add basic validation and normalization for autonames to Add basic validation and normalization for autonames (S).Aug 21 2026, 8:10 AM

Change #1333245 had a related patch set uploaded (by Mareike Heuer; author: Mareike Heuer):

[mediawiki/extensions/Cite@master] Add validation & normalization for custom auto-generated ref names

https://gerrit.wikimedia.org/r/1333245

Change #1335010 had a related patch set uploaded (by Gabriel Birke; author: Gabriel Birke):

[mediawiki/extensions/Cite@master] Improve autoname validation & normalization tests

https://gerrit.wikimedia.org/r/1335010

Change #1333245 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Add validation & normalization for custom auto-generated ref names

https://gerrit.wikimedia.org/r/1333245

Change #1335010 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Improve autoname validation & normalization tests

https://gerrit.wikimedia.org/r/1335010

Tobi_WMDE_SW claimed this task.