Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API doesn't handle URI-escaped characters in parameters #702

Closed
bwarden opened this issue Feb 9, 2023 · 0 comments · Fixed by #703
Closed

API doesn't handle URI-escaped characters in parameters #702

bwarden opened this issue Feb 9, 2023 · 0 comments · Fixed by #703

Comments

@bwarden
Copy link
Contributor

bwarden commented Feb 9, 2023

Trying to retrieve both OLSR status and active AREDN alert messages, for example, the following query is ok:

$ GET 'http://localnode/cgi-bin/api?status=olsr,alerts'

{
  "pages": {
    "status": {
      "alerts": {
        "aredn": "",
        "local": ""
      },
      "olsr": {
        "nodes": "356",
        "entries": "1258"
      }
    }
  },
  "api_version": "1.5"
}

However, if I wrap this up nicely from some other program (like Home Assistant, for example), it might helpfully URI-encode the comma, confusing the API:

$ GET 'http://localnode/cgi-bin/api?status=olsr%2Calerts'

{
  "pages": {
    "status": [
    ]
  },
  "api_version": "1.5"
}

The underlying issue is that parseQueryString() simplistically splits on & and =. Fortunately, we already have luci.http.urldecode_params() available, so we should use that instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant