Lucas_Werkmeister_WMDE added a comment.
I think I know the answer to one question: why does this issue only affect the data type string, not e. g. external ID or URL? Because string is the only data type we parse in JavaScript. For every other data type, we parse the value in JavaScript by sending it to the `wbparsevalue` API and thereby calling the PHP parser. The PHP parser for strings is fairly simple, but one thing it does is remove leading and trailing whitespace, such as the `\r\n` that are causing the problem. (Another thing it does is Unicode normalization.) The JS parser doesn’t do this, so when the Wikibase frontend tries to send a string value that was parsed in JS (and therefore still has the `\r\n`) to the backend, there’s an error because the whitespace should have been removed. My proposed solution <https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/629721> is to stop using the JS `StringParser` and parse strings via PHP too, like all other data values. I have some idea about another question: why does this issue go away if you add and remove a space elsewhere in the string? Because ValueView already removes line breaks from the input. <https://gerrit.wikimedia.org/g/data-values/value-view/+/98597119b08d89f91c4f6021d6dae6ac25d8e8e4/lib/jquery/jquery.inputautoexpand.js#212>. It subscribes to the `eachchange` event and replaces all line breaks (DOS or Unix) with the empty string. Then why does the bug exist at all? That’s the part I don’t understand… at the HTML level, the `\r\n` is gone immediately after paste, but I guess it must be persisted somewhere in JS until the next time the input changes. TASK DETAIL https://phabricator.wikimedia.org/T261942 EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/ To: guergana.tzatchkova, Lucas_Werkmeister_WMDE Cc: Lucas_Werkmeister_WMDE, toan, Lydia_Pintscher, Nikki, Aklapper, Addshore, Akuckartz, Iflorez, darthmon_wmde, alaa_wmde, Nandana, Lahi, Gq86, GoranSMilovanovic, QZanden, LawExplorer, _jensen, rosalieper, Scott_WUaS, Jonas, Wikidata-bugs, aude, Mbch331
_______________________________________________ Wikidata-bugs mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs
