114 |
114 |
115 @param url URL to get the credentials for (QUrl) |
115 @param url URL to get the credentials for (QUrl) |
116 @param realm realm to get the credentials for (string) |
116 @param realm realm to get the credentials for (string) |
117 @return key string (string) |
117 @return key string (string) |
118 """ |
118 """ |
|
119 authority = url.authority() |
|
120 if authority.startswith("@"): |
|
121 authority = authority[1:] |
119 if realm: |
122 if realm: |
120 key = "{0}://{1} ({2})".format( |
123 key = "{0}://{1} ({2})".format( |
121 url.scheme(), url.authority(), realm) |
124 url.scheme(), authority, realm) |
122 else: |
125 else: |
123 key = "{0}://{1}".format(url.scheme(), url.authority()) |
126 key = "{0}://{1}".format(url.scheme(), authority) |
124 return key |
127 return key |
125 |
128 |
126 def getFileName(self): |
129 def getFileName(self): |
127 """ |
130 """ |
128 Public method to get the file name of the passwords file. |
131 Public method to get the file name of the passwords file. |
432 @param url URL to be stripped (QUrl) |
435 @param url URL to be stripped (QUrl) |
433 @return stripped URL (QUrl) |
436 @return stripped URL (QUrl) |
434 """ |
437 """ |
435 cleanUrl = QUrl(url) |
438 cleanUrl = QUrl(url) |
436 cleanUrl.setQueryItems([]) |
439 cleanUrl.setQueryItems([]) |
|
440 cleanUrl.setUserInfo("") |
|
441 |
|
442 authority = cleanUrl.authority() |
|
443 if authority.startswith("@"): |
|
444 authority = authority[1:] |
|
445 cleanUrl = QUrl("{0}://{1}{2}".format( |
|
446 cleanUrl.scheme(), authority, cleanUrl.path())) |
437 cleanUrl.setFragment("") |
447 cleanUrl.setFragment("") |
438 cleanUrl.setUserInfo("") |
448 |
439 return cleanUrl |
449 return cleanUrl |
440 |
450 |
441 def __findForm(self, webPage, data, boundary=None): |
451 def __findForm(self, webPage, data, boundary=None): |
442 """ |
452 """ |
443 Private method to find the form used for logging in. |
453 Private method to find the form used for logging in. |
452 form = LoginForm() |
462 form = LoginForm() |
453 if boundary is not None: |
463 if boundary is not None: |
454 args = self.__extractMultipartQueryItems(data, boundary) |
464 args = self.__extractMultipartQueryItems(data, boundary) |
455 else: |
465 else: |
456 argsUrl = QUrl.fromEncoded( |
466 argsUrl = QUrl.fromEncoded( |
457 QByteArray("foo://bar.com/?" + data.replace(b"+", b"%20"))) |
467 QByteArray("foo://bar.com/?" + QUrl.fromPercentEncoding( |
|
468 data.replace(b"+", b"%20")))) |
458 encodedArgs = argsUrl.queryItems() |
469 encodedArgs = argsUrl.queryItems() |
459 args = set() |
470 args = set() |
460 for arg in encodedArgs: |
471 for arg in encodedArgs: |
461 key = arg[0] |
472 key = arg[0] |
462 value = arg[1] |
473 value = arg[1] |