Mercurial > irccd
changeset 777:1b17b2af5a6b
Plugin links: add query and fix use-after-free
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 31 Oct 2018 13:43:25 +0100 |
parents | 27a6cbb18897 |
children | 3ff081c72250 |
files | plugins/links/uri.cpp |
diffstat | 1 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/links/uri.cpp Tue Oct 30 13:45:55 2018 +0100 +++ b/plugins/links/uri.cpp Wed Oct 31 13:43:25 2018 +0100 @@ -48,11 +48,12 @@ UriParserStateA state; UriUriA hnd; uri ret; + string copy = match[1].str(); scope_exit exit([&hnd] { uriFreeUriMembersA(&hnd); }); state.uri = &hnd; - if (uriParseUriA(&state, match[1].str().c_str()) != URI_SUCCESS) + if (uriParseUriA(&state, copy.c_str()) != URI_SUCCESS) return nullopt; if (hnd.scheme.first) @@ -80,6 +81,12 @@ if (ret.path.empty()) ret.path = "/"; + // Add query if needed. + if (hnd.query.first) { + ret.path += "?"; + ret.path += string(hnd.query.first, hnd.query.afterLast - hnd.query.first); + } + return ret; }