Issues

Issue #21 resolved

_looks_like_ipaddress() fails for certain DNS hostnames

Anonymous created an issue

When the HOST setting for a database is set to a host name of the form x.y.z.net (x,y,z being arbitrary strings), and I run "python manage.py sql SomeDjangoApp", _looks_like_ipaddress fails because it calls int() on the string x, which raises an exception (below).

Traceback (most recent call last): File "manage.py", line 14, in <module> execute_manager(settings) File "c:\Python27\lib\site-packages\django\core\management__init.py", line 459, in execute_manager utility.execute() File "c:\Python27\lib\site-packages\django\core\management__init.py", line 382, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "c:\Python27\lib\site-packages\django\core\management\base.py", line 196, in run_from_argv self.execute(args, options.dict) File "c:\Python27\lib\site-packages\django\core\management\base.py", line 232, in execute output = self.handle(*args, options) File "c:\Python27\lib\site-packages\django\core\management\base.py", line 304, in handle app_output = self.handle_app(app, *options) File "c:\Python27\lib\site-packages\django\core\management\commands\sql.py", l ine 19, in handle_app return u'\n'.join(sql_create(app, self.style, connections[options.get('datab ase')])).encode('utf-8') File "c:\Python27\lib\site-packages\django\core\management\sql.py", line 26, i n sql_create tables = connection.introspection.table_names() File "c:\Python27\lib\site-packages\django\db\backends__init.py", line 895, in table_names cursor = self.connection.cursor() File "c:\Python27\lib\site-packages\django\db\backends__init.py", line 306, in cursor cursor = self.make_debug_cursor(self._cursor()) File "c:\Python27\lib\site-packages\sqlserver_ado\base.py", line 193, in _curs or self.connect() File "c:\Python27\lib\site-packages\sqlserver_ado\base.py", line 166, in con nect make_connection_string(self.settings_dict), File "c:\Python27\lib\site-packages\sqlserver_ado\base.py", line 71, in make_c onnection_string if not _looks_like_ipaddress(db_host): File "c:\Python27\lib\site-packages\sqlserver_ado\base.py", line 32, in _looks _like_ipaddress if not 0 <= int(item) <= 255: ValueError: invalid literal for int() with base 10: 'x'

Comments (2)

  1. Michael Manfre repo owner

    The HOST is only checked for an IP Address when you specify a port. I'm not sure if the drivers still require an IP address to be used with a port, or if you can specify a FQDN. Either way, the IP address validation should not crash. Whether or not a FQDN may be used with a PORT in the connection string (for a particular driver) is out of scope for this issue.

  2. Log in to comment