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

In API to create new wiki, sending ampersand in name field results in '&' #9856

Open
krcrouse opened this issue Dec 31, 2021 · 0 comments
Labels

Comments

@krcrouse
Copy link

I believe this is a bug in how the API is processing the strings in the request body for wiki creation - but this doesn't appear when using the manual online interface.

Through the online interface, there is no issue creating a new wiki page with an ampersand. Pressing the new button and typing A & B creates a wiki that appears as A & B in the wiki panel and that has a link of https://osf.io/{node_id}/wiki/A%20%26%20B/

The processor that handles API requests, on the other hand, is not handling this correctly for the name field, at least when using the native requests library with python:

  • If you pass in the unescaped "A & B" in the request body, the name in the Wiki Panel appears as A & B; however, the formatted title appears correct when reading the page, presumably because the website is rendering the &
  • If you attempt to escape it by passing in "A %26 B" or "A%20%26%20B" or "A+%26+B", these are all fully escaped and appear as listed.

Trivial example that leads to the described behavior.

import requests 

resp = requests.post(
    f'https://api.osf.io/v2/nodes/{node_id}/wikis/', 
    headers={"Authorization" : "Bearer " + access_token},
    data={
        'type': 'wikis',
        'content': "#Heading\n\nText text text",
        'name': "A & B",
    }) 

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

No branches or pull requests

2 participants