Page MenuHomePhabricator

API: Allow to pass whitespaces in MultiValue parameters
Closed, ResolvedPublic

Description

Currently the API tread MultiValue parameter like titles with a single value consists of whitespaces like a not preset parameter:

api.php?format=json&action=query&titles=%20 is the same like api.php?format=json&action=query and returns

{
  "batchcomplete": ""
}

This is inconsistent because on multiple values (separated by | or by %1f) a whitespace-only value can pass and generates an error message:

api.php?format=json&action=query&titles=%20|foo is responded with

{
  "batchcomplete": "",
  "query": {
    "pages": {
      "-2": {
        "ns": 0,
        "title": "foo",
        "missing": ""
      },
      "-1": {
        "title": " ",
        "invalidreason": "The requested page title is empty or contains only the name of a namespace.",
        "invalid": ""
      }
    }
  }
}

The missing query key in the response can also produce errors in precessing the response like in T185400.

Expected result: A whitespace-only single value should also pass the API and return an error message:

{
  "batchcomplete": "",
  "query": {
    "pages": {
      "-1": {
        "title": " ",
        "invalidreason": "The requested page title is empty or contains only the name of a namespace.",
        "invalid": ""
      }
    }
  }
}

Details

Related Gerrit Patches:

Event Timeline

Fomafix created this task.Jan 28 2018, 5:57 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 28 2018, 5:57 PM

Change 405609 had a related patch set uploaded (by Fomafix; owner: Fomafix):
[mediawiki/core@master] [WIP] API: Allow to pass whitespaces in MultiValue

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

Anomie moved this task from Unsorted to Needs Review on the MediaWiki-API board.Jan 29 2018, 2:37 PM

Change 405609 merged by jenkins-bot:
[mediawiki/core@master] API: Allow to pass whitespaces in MultiValue

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

Anomie closed this task as Resolved.Jan 29 2018, 3:38 PM