Commit b1152f5c authored by Thomas Guillem's avatar Thomas Guillem

keystore: store/find a decoded path

parent 76ae877d
...@@ -131,6 +131,9 @@ find_closest_path(vlc_keystore_entry *p_entries, unsigned i_count, ...@@ -131,6 +131,9 @@ find_closest_path(vlc_keystore_entry *p_entries, unsigned i_count,
{ {
vlc_keystore_entry *p_match_entry = NULL; vlc_keystore_entry *p_match_entry = NULL;
size_t i_last_pathlen = 0; size_t i_last_pathlen = 0;
char *psz_decoded_path = vlc_uri_decode_duplicate(psz_path);
if (psz_decoded_path == NULL)
return NULL;
/* Try to find the entry that has the closest path to psz_url */ /* Try to find the entry that has the closest path to psz_url */
for (unsigned int i = 0; i < i_count; ++i) for (unsigned int i = 0; i < i_count; ++i)
...@@ -139,13 +142,14 @@ find_closest_path(vlc_keystore_entry *p_entries, unsigned i_count, ...@@ -139,13 +142,14 @@ find_closest_path(vlc_keystore_entry *p_entries, unsigned i_count,
const char *psz_entry_path = p_entry->ppsz_values[KEY_PATH]; const char *psz_entry_path = p_entry->ppsz_values[KEY_PATH];
size_t i_entry_pathlen = strlen(psz_entry_path); size_t i_entry_pathlen = strlen(psz_entry_path);
if (strncasecmp(psz_path, psz_entry_path, i_entry_pathlen) == 0 if (strncasecmp(psz_decoded_path, psz_entry_path, i_entry_pathlen) == 0
&& i_entry_pathlen > i_last_pathlen) && i_entry_pathlen > i_last_pathlen)
{ {
i_last_pathlen = i_entry_pathlen; i_last_pathlen = i_entry_pathlen;
p_match_entry = p_entry; p_match_entry = p_entry;
} }
} }
free(psz_decoded_path);
return p_match_entry; return p_match_entry;
} }
...@@ -430,7 +434,8 @@ vlc_credential_store(vlc_credential *p_credential) ...@@ -430,7 +434,8 @@ vlc_credential_store(vlc_credential *p_credential)
const vlc_url_t *p_url = p_credential->p_url; const vlc_url_t *p_url = p_credential->p_url;
char *psz_path = NULL; char *psz_path = NULL;
if (protocol_store_path(p_url) && (psz_path = strdup(p_url->psz_path))) if (protocol_store_path(p_url)
&& (psz_path = vlc_uri_decode_duplicate(p_url->psz_path)) != NULL)
{ {
char *p_slash; char *p_slash;
if (protocol_is_smb(p_url)) if (protocol_is_smb(p_url))
...@@ -473,7 +478,10 @@ vlc_credential_store(vlc_credential *p_credential) ...@@ -473,7 +478,10 @@ vlc_credential_store(vlc_credential *p_credential)
if (asprintf(&psz_label, "LibVLC password for %s://%s%s", if (asprintf(&psz_label, "LibVLC password for %s://%s%s",
p_url->psz_protocol, p_url->psz_host, p_url->psz_protocol, p_url->psz_host,
psz_path ? psz_path : "") == -1) psz_path ? psz_path : "") == -1)
{
free(psz_path);
return false; return false;
}
bool b_ret = vlc_keystore_store(p_credential->p_keystore, ppsz_values, bool b_ret = vlc_keystore_store(p_credential->p_keystore, ppsz_values,
(const uint8_t *)p_credential->psz_password, (const uint8_t *)p_credential->psz_password,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment