public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: Noah Sanci <nsanci@redhat.com>, "Frank Ch. Eigler" <fche@redhat.com>
Cc: elfutils-devel@sourceware.org
Subject: Re: [Bug debuginfod/28034] client-side %-escape url characters
Date: Wed, 08 Sep 2021 15:38:43 +0200	[thread overview]
Message-ID: <e785e77b620f34cbcaf5f6b32b7912f429a89785.camel@klomp.org> (raw)
In-Reply-To: <CAJXA7qjp0nXoZb9QS+rGbpEQK4HR9TyQBi5YaFtNYVr++goFmw@mail.gmail.com>

Hi Noah,

This looks good, but the description is not really what the patch does.
It is part of the PR28034 fix, but repeating that problem statement
doesn't really make clear what this patch is about. Could explain in
the commit message that curl_easy_escape () also escapes '/' to '%2F'
and that we want to reverse that back to '/'?

Also some (tiny) optimization hints.

This can be done outside/before the loop

  /* Initialize each handle.  */
  for (int i = 0; i < num_urls; i++)

So you only need to escape once. You of course then need to make sure
the escaped_string is freed after the loop.

We already check that the first char is a '/'. It seems silly to curl
escape that one and then unescape it again. So maybe curl_easy_escape
(data[i].handle, filename + 1, 0) and then change the snprintf pattern
to "%s/%s/%s/%s"?
            ^ the slash got readded here.

The strlen inside the while loop can also be done outside and then
calculated instead of running strlen on the tail every time.

size_t escaped_strlen = strlen (escaped_string);
while( (loc = strstr(loc, "%2F")) )
  {
     loc[0] = '/';
     // pull the string back after replacement
     escaped_strlen -= (loc + 3) - escaped_string);
     memmove(loc+1, loc+3, escaped_strlen + 1);
  }

(Note, not even compiled, so I might be wrong)

Lastly I assume there are already testcases that cover this
functionality? Just wanting to know how you tested it.

Thanks,

Mark

  reply	other threads:[~2021-09-08 13:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-26 19:27 Noah Sanci
2021-08-26 21:02 ` Frank Ch. Eigler
2021-08-27 14:44   ` Noah Sanci
2021-08-27 15:07     ` Noah Sanci
2021-08-27 15:30       ` Noah Sanci
2021-09-08 13:38         ` Mark Wielaard [this message]
2021-09-09 17:28           ` Noah Sanci
2021-09-12 17:24             ` Mark Wielaard
2021-09-13 16:20               ` Noah Sanci
2021-09-13 18:11                 ` Noah Sanci
2021-09-16 10:35                   ` Mark Wielaard

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=e785e77b620f34cbcaf5f6b32b7912f429a89785.camel@klomp.org \
    --to=mark@klomp.org \
    --cc=elfutils-devel@sourceware.org \
    --cc=fche@redhat.com \
    --cc=nsanci@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).