web2py / pydal

A pure Python Database Abstraction Layer
BSD 3-Clause "New" or "Revised" License
493 stars 137 forks source link

The connection string contains the ‘@’ sign #495

Open bufubaoni opened 7 years ago

bufubaoni commented 7 years ago

userpassword is Prod!@#xxx the connection string ismysql://<username>:Prod!@#252@host/realtime_db then it can not be recognized correctly host

I see that the source code can not contain @ symbols, in addition to modify the source code there are other ways.

BuhtigithuB commented 6 years ago

I can't find any mention of the limitation in the book : http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Connection-strings--the-uri-parameter-

Here it specified the supported string format : https://github.com/web2py/pydal/blob/53661bbf9d6f064fb57ca806aaa1cb524687c5fb/pydal/base.py#L88

It a limitation and I guess removing it would be requires much more advancing technics or at least another stage of filtering... Like let say there is now 2+ "@" in your password...

You surely already know the work around (change your password)...

I see a possible way to support it more easily in the future as there is this experimental possibility : https://github.com/web2py/pydal/blob/53661bbf9d6f064fb57ca806aaa1cb524687c5fb/pydal/base.py#L186

So if the 'uri' is splited into it component we wouldn't have to parse the connection string, but instead get the different members of it from the dictionary, that would solve your need in an elegant manner...

You could have look at the code and if you figure it out how to make the experimental dictionary DAL connection definition support a splitted key value connection string you are welcome to propose a PR for it... It would solve you issue and enhance the capability of pyDAL...

Richard

BuhtigithuB commented 6 years ago

Did you try my suggestion??

I suggest to set this one as "won't fix", as I am pretty sure that the experimental feature would allow the use of an "@" character in password and if not, then it probably a bad idea to over engineer the DAL to allow such use case.

We could add a notice in the book and in welcome app near connection string and pyDAL that password can't have an "@" character.

mdipierro commented 6 years ago

sorry overlooked this. I believe there is (was) a way to escape the password. If that’s borken bust me fixed. Will look asap.

On Apr 23, 2018, at 8:34 PM, BuhtigithuB notifications@github.com wrote:

Did you try my suggestion??

I suggest to set this one as "won't fix", as I am pretty sure that the experimental feature would allow the use of an "@" character in password and if not, then it probably a bad idea to over engineer the DAL to allow such use case.

We could add a notice in the book and in welcome app near connection string and pyDAL that password can't have an "@" character.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/web2py/pydal/issues/495#issuecomment-383774545, or mute the thread https://github.com/notifications/unsubscribe-auth/AA68zw_FbchbUGUn5sJN16qPXV1LI5slks5troEogaJpZM4PYdbA.

balajiv32 commented 5 years ago

Please fix this @ issue as ,it is stopping us in implementing in most of our client projects

ansraliant commented 5 years ago

I am affected as well by this. Tried to escape the '@' character on the string, but still it recognizes the host from the first '@' it finds

ansraliant commented 5 years ago

Seems the issue is this regex

REGEX_URI = \
         '^(?P<user>[^:@]+)(:(?P<password>[^@]*))?' \
        r'@(?P<host>[^:/]*|\[[^\]]+\])(:(?P<port>\d+))?' \
         '/(?P<db>[^?]+)' \
        r'(\?(?P<uriargs>.*))?$'
WenTao-Love commented 4 years ago

What should I do? I'm in the same situation……

WenTao-Love commented 4 years ago

Now I found that pydal can set the parameter "decode_ credentials"