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

[server] views: comments: Check using get(), not 'in' #895

Merged
merged 2 commits into from
May 28, 2022

Conversation

ix5
Copy link
Member

@ix5 ix5 commented May 28, 2022

Checklist

  • All new and existing tests are passing
  • (If adding features:) I have added tests to cover my changes
  • (If docs changes needed:) I have updated the documentation accordingly.
  • I have added an entry to CHANGES.rst because this is a user-facing change or an important bugfix
  • I have written proper commit message(s)

What changes does this Pull Request introduce?

Previously, if a dict item was supplied by the JS client but contained an invalid value such as null, the server would only check if the dict key was provided, not if its value was falsy.

>>> mydict = dict(a='hi', b=None)
>>> 'b' in mydict
True
>>> 'b' not in mydict
False

Instead, use .get() and check if the value is empty. Then, for instance, attempt to parse thread uris if payload title is invalid instead of simply accepting null as thread title.

Also add a test to check this behavior.

Why is this necessary?

Fixes: #874

ix5 added 2 commits May 29, 2022 00:23
Previously, if a dict item was supplied by the JS client but
contained an invalid value such as `null`, the server would
only check if the dict key was provided, not if its value
was falsy.

```python
>>> mydict = dict(a='hi', b=None)
>>> 'b' in mydict
True
>>> 'b' not in mydict
False
```

Instead, use `.get()` and check if the value is empty. Then,
for instance, attempt to parse thread uris if payload title
is invalid instead of simply accepting `null` as thread
title.

Fixes: isso-comments#874
@ix5 ix5 added server (Python) server code bug labels May 28, 2022
@ix5 ix5 added this to the 0.13 milestone May 28, 2022
@ix5 ix5 merged commit 15c0172 into isso-comments:master May 28, 2022
@ix5 ix5 deleted the views-get-not-in branch May 28, 2022 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug server (Python) server code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Email notifications for comment replies say "Re: New comment posted on None"
1 participant