mirror of
https://github.com/mirror/wget.git
synced 2025-01-01 07:50:11 +08:00
Don't save user/pw with --xattr
Also the Referer info is reduced to scheme+host+port. * src/ftp.c (getftp): Change params of set_file_metadata() * src/http.c (gethttp): Change params of set_file_metadata() * src/xattr.c (set_file_metadata): Remove user/password from origin URL, reduce Referer value to scheme/host/port. * src/xattr.h: Change prototype of set_file_metadata()
This commit is contained in:
parent
c125d24762
commit
3cdfb594cf
@ -1580,7 +1580,7 @@ Error in server response, closing control connection.\n"));
|
|||||||
|
|
||||||
#ifdef ENABLE_XATTR
|
#ifdef ENABLE_XATTR
|
||||||
if (opt.enable_xattr)
|
if (opt.enable_xattr)
|
||||||
set_file_metadata (u->url, NULL, fp);
|
set_file_metadata (u, NULL, fp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fd_close (local_sock);
|
fd_close (local_sock);
|
||||||
|
@ -4113,9 +4113,9 @@ gethttp (const struct url *u, struct url *original_url, struct http_stat *hs,
|
|||||||
if (opt.enable_xattr)
|
if (opt.enable_xattr)
|
||||||
{
|
{
|
||||||
if (original_url != u)
|
if (original_url != u)
|
||||||
set_file_metadata (u->url, original_url->url, fp);
|
set_file_metadata (u, original_url, fp);
|
||||||
else
|
else
|
||||||
set_file_metadata (u->url, NULL, fp);
|
set_file_metadata (u, NULL, fp);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
24
src/xattr.c
24
src/xattr.c
@ -21,6 +21,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "utils.h"
|
||||||
#include "xattr.h"
|
#include "xattr.h"
|
||||||
|
|
||||||
#ifdef USE_XATTR
|
#ifdef USE_XATTR
|
||||||
@ -57,7 +58,7 @@ write_xattr_metadata (const char *name, const char *value, FILE *fp)
|
|||||||
#endif /* USE_XATTR */
|
#endif /* USE_XATTR */
|
||||||
|
|
||||||
int
|
int
|
||||||
set_file_metadata (const char *origin_url, const char *referrer_url, FILE *fp)
|
set_file_metadata (const struct url *origin_url, const struct url *referrer_url, FILE *fp)
|
||||||
{
|
{
|
||||||
/* Save metadata about where the file came from (requested, final URLs) to
|
/* Save metadata about where the file came from (requested, final URLs) to
|
||||||
* user POSIX Extended Attributes of retrieved file.
|
* user POSIX Extended Attributes of retrieved file.
|
||||||
@ -67,13 +68,28 @@ set_file_metadata (const char *origin_url, const char *referrer_url, FILE *fp)
|
|||||||
* [http://0pointer.de/lennart/projects/mod_mime_xattr/].
|
* [http://0pointer.de/lennart/projects/mod_mime_xattr/].
|
||||||
*/
|
*/
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
char *value;
|
||||||
|
|
||||||
if (!origin_url || !fp)
|
if (!origin_url || !fp)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
retval = write_xattr_metadata ("user.xdg.origin.url", escnonprint_uri (origin_url), fp);
|
value = url_string (origin_url, URL_AUTH_HIDE);
|
||||||
if ((!retval) && referrer_url)
|
retval = write_xattr_metadata ("user.xdg.origin.url", escnonprint_uri (value), fp);
|
||||||
retval = write_xattr_metadata ("user.xdg.referrer.url", escnonprint_uri (referrer_url), fp);
|
xfree (value);
|
||||||
|
|
||||||
|
if (!retval && referrer_url)
|
||||||
|
{
|
||||||
|
struct url u;
|
||||||
|
|
||||||
|
memset(&u, 0, sizeof(u));
|
||||||
|
u.scheme = referrer_url->scheme;
|
||||||
|
u.host = referrer_url->host;
|
||||||
|
u.port = referrer_url->port;
|
||||||
|
|
||||||
|
value = url_string (&u, 0);
|
||||||
|
retval = write_xattr_metadata ("user.xdg.referrer.url", escnonprint_uri (value), fp);
|
||||||
|
xfree (value);
|
||||||
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,13 @@
|
|||||||
along with this program; if not, see <http://www.gnu.org/licenses/>. */
|
along with this program; if not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <url.h>
|
||||||
|
|
||||||
#ifndef _XATTR_H
|
#ifndef _XATTR_H
|
||||||
#define _XATTR_H
|
#define _XATTR_H
|
||||||
|
|
||||||
/* Store metadata name/value attributes against fp. */
|
/* Store metadata name/value attributes against fp. */
|
||||||
int set_file_metadata (const char *origin_url, const char *referrer_url, FILE *fp);
|
int set_file_metadata (const struct url *origin_url, const struct url *referrer_url, FILE *fp);
|
||||||
|
|
||||||
#if defined(__linux)
|
#if defined(__linux)
|
||||||
/* libc on Linux has fsetxattr (5 arguments). */
|
/* libc on Linux has fsetxattr (5 arguments). */
|
||||||
|
Loading…
Reference in New Issue
Block a user