public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: "Frank Ch. Eigler" <fche@redhat.com>
To: Noah Sanci <nsanci@redhat.com>
Cc: elfutils-devel@sourceware.org
Subject: Re: [Bug debuginfod/28034] client-side %-escape url characters
Date: Thu, 26 Aug 2021 17:02:13 -0400	[thread overview]
Message-ID: <20210826210213.GM416@redhat.com> (raw)
In-Reply-To: <CAJXA7qjt7-ZwThr0do3pGFg5i+bfa-fvDSOkq=w8Q8euNAG12g@mail.gmail.com>

Hi -

>            /* PR28034 escape characters in completed url to %hh format. */
> -          char *escaped_string;
> -          escaped_string = curl_easy_escape(data[i].handle, filename, 0);
> -          if (!escaped_string)
> +          char escaped_string[PATH_MAX] = {'\0'};
> +          char *loc = (char *) filename;
> +          char *loc2;
> +          char *tmp;
> +          for(size_t j = 0; j < strlen(filename); ++j)
>              {
> -              rc = -ENOMEM;
> -              goto out2;
> +              loc2 = strstr(loc, "/");
> +              // If the first character is a '/'
> [...]

Holy cow that's a lot of work to do it this way.
A couple of alternatives:

- ditch curl_easy_escape :-( and use a
  malloc(strlen(x)*3)
  byte-by-byte copy from source string into destination
    if not [a-zA-Z0-9/.~] then %-escape

or:
- keep curl_easy_escape and postprocess
  byte-by-byte examine the result of curl_easy_escape
  - if seeing a "%2F", replace the % with a / and memmove the
    rest of the string 2 bytes ahead

It shouldn't need strtok or strstr or a lot of logic or stuff like
that really.

- FChE


  reply	other threads:[~2021-08-26 21:02 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 [this message]
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
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=20210826210213.GM416@redhat.com \
    --to=fche@redhat.com \
    --cc=elfutils-devel@sourceware.org \
    --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).