Page MenuHomePhabricator

Use alternative separator character when calling wbparsevalue
Closed, ResolvedPublic

Description

wbparsevalue accepts multiple strings to parse in one request. These are passed as a pipe-separated list via the values parameter. This means that any client code, including the Wikibase UI code, needs to use the alternative separator character:

The API offers an alternative separator for multivalue parameters: If a string starts with ASCII code \x1F (Unit Separator), any other occurrence of \x1F in the string will be treated as a separator, and pipe characters are treated as literal. See ApiBase::explodeMultiValue() for reference.

Clients that want to allow pipe characters to be present in aliases need to prepend the parameter value with \x1F.

See also T167785: Use alternative separator character when calling wbsetaliases

Patch-For-Review:

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 2:51 AM
bzimport set Reference to bz62925.
bzimport added a subscriber: Unknown Object (MLST).
Lydia_Pintscher removed a subscriber: Unknown Object (MLST).
Lydia_Pintscher removed a subscriber: Unknown Object (MLST).
Ricordisamoa renamed this task from wbparsevalue cannot process strings that contain a pipe "|" caharcter to wbparsevalue cannot process strings that contain a pipe "|" character.Sep 5 2015, 1:58 AM
Ricordisamoa set Security to None.
Ricordisamoa subscribed.

This is indeed resolved: https://www.wikidata.org/w/api.php?action=wbparsevalue&datatype=string&values=%1Ffoo|bar%1Fbaaar|foo0

{
    "results": [
        {
            "raw": "foo|bar",
            "value": "foo|bar",
            "type": "string"
        },
        {
            "raw": "baaar|foo0",
            "value": "baaar|foo0",
            "type": "string"
        }
    ]
}
daniel renamed this task from wbparsevalue cannot process strings that contain a pipe "|" character to Use alternative separator character when calling wbparsevalue.Jun 20 2017, 8:20 AM
daniel reopened this task as Open.
daniel updated the task description. (Show Details)

Re-opening - the issue as described was solved, but the concrete problem was not. I reworded the ticket to reflect this.

The point is: even though the API module indeed has a mechanism for using an alternative separator character, our UI code doesn't use it. We need to change that so we can process input that contains a pipe character.

Change 360354 had a related patch set uploaded (by Thiemo Mättig (WMDE); owner: Thiemo Mättig (WMDE)):
[mediawiki/extensions/WikibaseJavaScriptApi@master] [WIP] Use alternative separator character in API requests

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

Change 360354 merged by jenkins-bot:
[mediawiki/extensions/WikibaseJavaScriptApi@master] Use alternative separator character in API requests

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

Change 363786 had a related patch set uploaded (by Thiemo Mättig (WMDE); owner: Thiemo Mättig (WMDE)):
[mediawiki/extensions/Wikibase@master] Update JavaScript API dependency to 2.2.1

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

thiemowmde updated the task description. (Show Details)
thiemowmde moved this task from Doing to Review on the Wikidata-Former-Sprint-Board board.
thiemowmde moved this task from incoming to in progress on the Wikidata board.

Change 363786 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Update JavaScript API dependency to 2.2.2

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

thiemowmde removed a project: Patch-For-Review.
thiemowmde updated the task description. (Show Details)