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

Domain not handle None object #143

Closed
reahaas opened this issue Feb 27, 2020 · 4 comments · Fixed by #231
Closed

Domain not handle None object #143

reahaas opened this issue Feb 27, 2020 · 4 comments · Fixed by #231
Labels
wontfix Issue: Out of scope

Comments

@reahaas
Copy link
Contributor

reahaas commented Feb 27, 2020

validators None issue:

code:

def validator_test():
    import validators
    if validators.domain(None):
        print("None object is FQDN")
    else:
        print("None object is NOT FQDN")

error

Traceback (most recent call last):
  File "/home/vagrant/scadafence/rea-helper.py", line 49, in <module>
    main()
  File "/home/vagrant/scadafence/rea-helper.py", line 45, in main
    validator_test()
  File "/home/vagrant/scadafence/rea-helper.py", line 33, in validator_test
    if validators.domain(None):
  File "</home/vagrant/scadafence/venv/local/lib/python2.7/site-packages/decorator.pyc:decorator-gen-2>", line 2, in domain
  File "/home/vagrant/scadafence/venv/local/lib/python2.7/site-packages/validators/utils.py", line 83, in wrapper
    value = func(*args, **kwargs)
  File "/home/vagrant/scadafence/venv/local/lib/python2.7/site-packages/validators/domain.py", line 60, in domain
    return pattern.match(to_unicode(value).encode('idna').decode('ascii'))
AttributeError: 'NoneType' object has no attribute 'encode'
@reahaas
Copy link
Contributor Author

reahaas commented Feb 27, 2020

Of course, I can check it before using the validators, but the validator already checks it, so why not to handle the "None" case?
After all, None is not an FQDN...

@reahaas
Copy link
Contributor Author

reahaas commented Feb 27, 2020

a solution may be in the catch statement:

    try:
        return pattern.match(to_unicode(value).encode('idna').decode('ascii'))
    except (UnicodeError, AttributeError) as e:
        return False

@reahaas
Copy link
Contributor Author

reahaas commented Feb 27, 2020

Open new PR:
#144

@reahaas
Copy link
Contributor Author

reahaas commented Feb 27, 2020

I looked at other validators (not only the domain) and it seems that all of them don't handling the "None" as input...
If this PR will be approved I can also fix all the validators to handle the "None" case...

@yozachar yozachar added the wontfix Issue: Out of scope label Mar 2, 2023
yozachar added a commit to yozachar/pyvalidators that referenced this issue Mar 2, 2023
@yozachar yozachar closed this as not planned Won't fix, can't repro, duplicate, stale Mar 2, 2023
yozachar added a commit to yozachar/pyvalidators that referenced this issue Mar 2, 2023
- Uses type hints, improve docs
- Regards [RFC 1034](https://www.rfc-editor.org/rfc/rfc1034)
- Updates corresponding test functions

**Related items**

*Issues*

- Closes python-validators#52
- Closes python-validators#74
- Closes python-validators#81
- Closes python-validators#89
- Closes python-validators#95
- Closes python-validators#120
- Closes python-validators#124
- Closes python-validators#141
- Closes python-validators#143
- Closes python-validators#199
- Closes python-validators#204

*PRs*

- Closes python-validators#114
yozachar added a commit to yozachar/pyvalidators that referenced this issue Mar 2, 2023
- Uses type hints, improve docs
- Regards [RFC 1034](https://www.rfc-editor.org/rfc/rfc1034) and [RFC 2782](https://www.rfc-editor.org/rfc/rfc2782)
- Updates corresponding test functions

**Related items**

*Issues*

- Closes python-validators#52
- Closes python-validators#74
- Closes python-validators#81
- Closes python-validators#89
- Closes python-validators#95
- Closes python-validators#120
- Closes python-validators#124
- Closes python-validators#141
- Closes python-validators#143
- Closes python-validators#199
- Closes python-validators#204

*PRs*

- Closes python-validators#114
- Closes python-validators#179
yozachar added a commit to yozachar/pyvalidators that referenced this issue Mar 2, 2023
- Uses type hints, improve docs
- Regards [RFC 1034](https://www.rfc-editor.org/rfc/rfc1034) and [RFC 2782](https://www.rfc-editor.org/rfc/rfc2782)
- Updates corresponding test functions

**Related items**

*Issues*

- Closes python-validators#52
- Closes python-validators#74
- Closes python-validators#81
- Closes python-validators#89
- Closes python-validators#95
- Closes python-validators#120
- Closes python-validators#124
- Closes python-validators#141
- Closes python-validators#143
- Closes python-validators#199
- Closes python-validators#204

*PRs*

- Closes python-validators#114
- Closes python-validators#179
yozachar added a commit to yozachar/pyvalidators that referenced this issue Mar 2, 2023
- Uses type hints, improve docs
- Regards [RFC 1034](https://www.rfc-editor.org/rfc/rfc1034) and [RFC 2782](https://www.rfc-editor.org/rfc/rfc2782)
- Updates corresponding test functions

**Related items**

*Issues*

- Closes python-validators#52
- Closes python-validators#74
- Closes python-validators#81
- Closes python-validators#89
- Closes python-validators#95
- Closes python-validators#120
- Closes python-validators#124
- Closes python-validators#141
- Closes python-validators#143
- Closes python-validators#199
- Closes python-validators#204

*PRs*

- Closes python-validators#114
- Closes python-validators#179
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix Issue: Out of scope
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants