All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Aleksey Vasenev <margtu-fivt@ya.ru>
Cc: git@vger.kernel.org, Erik Faye-Lund <kusmabite@googlemail.com>,
	Karsten Blees <blees@dcon.de>
Subject: Re: [PATCH] wincred: fix get credential if username has @
Date: Wed, 19 Nov 2014 14:41:10 -0800	[thread overview]
Message-ID: <xmqq1toyreyh.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1416433652-6840-1-git-send-email-margtu-fivt@ya.ru> (Aleksey Vasenev's message of "Thu, 20 Nov 2014 00:47:32 +0300")

Aleksey Vasenev <margtu-fivt@ya.ru> writes:

>> To: git@vger.kernel.org
>> Cc: Junio C Hamano <gitster@pobox.com>, Aleksey Vasenev <margtu-fivt@ya.ru>

Sorry, but I am hardly qualified to review this one, especially
without any log message that explains what breaks and how it breaks
with the current code, which may lead the reader to understand how
the updated code fixes the issue.  Cc'ing me does not help us very
much.

    $ git shortlog --no-merges -n contrib/credential/wincred/

gives me a few names who may be able to give us some inputs, so I'll
Cc them.

Thanks.

> Signed-off-by: Aleksey Vasenev <margtu-fivt@ya.ru>
> ---
>  .../credential/wincred/git-credential-wincred.c    | 25 +++++++++++++++++++---
>  1 file changed, 22 insertions(+), 3 deletions(-)
>
> diff --git a/contrib/credential/wincred/git-credential-wincred.c b/contrib/credential/wincred/git-credential-wincred.c
> index a1d38f0..0061340 100644
> --- a/contrib/credential/wincred/git-credential-wincred.c
> +++ b/contrib/credential/wincred/git-credential-wincred.c
> @@ -111,14 +111,23 @@ static void write_item(const char *what, LPCWSTR wbuf, int wlen)
>   * Match an (optional) expected string and a delimiter in the target string,
>   * consuming the matched text by updating the target pointer.
>   */
> -static int match_part(LPCWSTR *ptarget, LPCWSTR want, LPCWSTR delim)
> +
> +static LPCWSTR wcsstr_last(LPCWSTR str, LPCWSTR find)
> +{
> +	LPCWSTR res = NULL, pos;
> +	for (pos = wcsstr(str, find); pos; pos = wcsstr(pos + 1, find))
> +		res = pos;
> +	return res;
> +}
> +
> +static int match_part_with_last(LPCWSTR *ptarget, LPCWSTR want, LPCWSTR delim, int last)
>  {
>  	LPCWSTR delim_pos, start = *ptarget;
>  	int len;
>  
>  	/* find start of delimiter (or end-of-string if delim is empty) */
>  	if (*delim)
> -		delim_pos = wcsstr(start, delim);
> +		delim_pos = last ? wcsstr_last(start, delim) : wcsstr(start, delim);
>  	else
>  		delim_pos = start + wcslen(start);
>  
> @@ -138,6 +147,16 @@ static int match_part(LPCWSTR *ptarget, LPCWSTR want, LPCWSTR delim)
>  	return !want || (!wcsncmp(want, start, len) && !want[len]);
>  }
>  
> +static int match_part(LPCWSTR *ptarget, LPCWSTR want, LPCWSTR delim)
> +{
> +	return match_part_with_last(ptarget, want, delim, 0);
> +}
> +
> +static int match_part_last(LPCWSTR *ptarget, LPCWSTR want, LPCWSTR delim)
> +{
> +	return match_part_with_last(ptarget, want, delim, 1);
> +}
> +
>  static int match_cred(const CREDENTIALW *cred)
>  {
>  	LPCWSTR target = cred->TargetName;
> @@ -146,7 +165,7 @@ static int match_cred(const CREDENTIALW *cred)
>  
>  	return match_part(&target, L"git", L":") &&
>  		match_part(&target, protocol, L"://") &&
> -		match_part(&target, wusername, L"@") &&
> +		match_part_last(&target, wusername, L"@") &&
>  		match_part(&target, host, L"/") &&
>  		match_part(&target, path, L"");
>  }

  reply	other threads:[~2014-11-19 22:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-12 22:52 [PATCH] wincred: fix get credential if username has @ Aleksey Vasenev
2014-11-19 21:47 ` Aleksey Vasenev
2014-11-19 22:41   ` Junio C Hamano [this message]
2015-01-25 21:12     ` Erik Faye-Lund
2015-01-26  4:25       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq1toyreyh.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=blees@dcon.de \
    --cc=git@vger.kernel.org \
    --cc=kusmabite@googlemail.com \
    --cc=margtu-fivt@ya.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.