Web2Py community,
I am rewriting this note, please disregard/delete the prior post (I'm not
getting updated on it)
Working with the DAL I noted that the Regular Expression does not allow for
host names that are directories such as "/tmp"
The following line is from DAL.py
[1]
re.compile('^(?P<user>[^:@]+)(\:(?P<password>[^@]*))?@(?P<host>[^\:@/]+)(\:(?P<port>[0-9]+))?/(?P<db>[^\?]+)(\?sslmode=(?P<sslmode>.+))?$')
Note that the 70th character in [1] above, "/" excludes the option of
having a host named "/tmp" however the following is a legitimate postgres
connection:
import psycopg2
conn_string = "host='/tmp' dbname='foobar' user='foo' password='bar'"
conn = psycopg2.connect(conn_string)
cursor = conn.cursor()
cursor.execute("SELECT * FROM foobar_table")
records = cursor.fetchall()
There are many instances where a UNIX user may prefer sockets over
localhost connections. The easiest work around I can think of is to change
[1] to the following:
[2]
re.compile('^(?P<user>[^:@]+)(\:(?P<password>[^@]*))?@(?P<host>[^\:@]+)(\:(?P<port>[0-9]+))?/(?P<db>[^\?]+)(\?sslmode=(?P<sslmode>.+))?$')
Where the "/" character exclusion is removed from the character class
definition for the group "host"
Best regards,
Babak