Page MenuHomePhabricator

Trim initial and trailing whitespace from captions on input and display
Open, Stalled, Needs TriagePublic

Description

Don't need it, don't want it, let's kill it.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptNov 16 2018, 11:32 PM

OK, I'm a little lost here. Tracing through the code as best I can, the captions end up (via EditEntity to LabelsChangeOpDeserializer and then StringNormalizer::trimToNFC) going to the trimWhitespace method, which should drop initial and terminal whitespace:

$trimmed = preg_replace( '/^\p{Z}+|\p{Z}+$/u', '', $trimmed );

Am I missing something obvious? @Addshore, do you have ideas?

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/WikibaseMediaInfo/+/475003 for a failing test, though it's failing in a different way than I expected?

So this happens in the ChangeOpDeserializers in Wikibase.

LabelChangeOpDeserializer has:

$this->stringNormalizer->trimToNFC( $serialization['value'] ) );

And that normalizer is a:

\Wikibase\Repo\ParsersWikibaseStringValueNormalizer

And the method does:

return $this->cleanupToNFC( $this->trimWhitespace( $inputString ) );
Jdforrester-WMF moved this task from To Do to Doing on the Structured Data Engineering board.
daniel added a subscriber: daniel.Dec 10 2018, 8:23 PM

Not all API modules use ChangeOpDeserializers. All *should* use that, but not all do. Especially the one for creating entities don't, IIRC.

Or maybe I'm wrong, and it's the SpecialPages for creating entities and editing terms that don't use ChangeOpDeserializers? In any case - most things do, and some things don't, sadly.

Ramsey-WMF changed the task status from Open to Stalled.Dec 17 2018, 5:27 PM
Ramsey-WMF added a subscriber: Ramsey-WMF.

Despite consultations with Wikibase experts, the fix for this is still a mystery.

greg added a project: Multimedia.Mar 7 2019, 10:59 PM
Ramsey-WMF moved this task from Untriaged to Next up on the Multimedia board.Mar 8 2019, 2:56 AM

This isn't pressing right now, so we'll get back to it at a later date.

Restricted Application added a project: Multimedia. · View Herald TranscriptAug 10 2019, 11:54 PM