Clean user, pass, and fragment from URL before writing
This commit is contained in:
parent
9be3982dc6
commit
651fa716b4
@ -10,6 +10,7 @@ use monolith::http::retrieve_asset;
|
|||||||
use monolith::utils::is_valid_url;
|
use monolith::utils::is_valid_url;
|
||||||
use reqwest::blocking::Client;
|
use reqwest::blocking::Client;
|
||||||
use reqwest::header::{HeaderMap, HeaderValue, USER_AGENT};
|
use reqwest::header::{HeaderMap, HeaderValue, USER_AGENT};
|
||||||
|
use reqwest::Url;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fs::{remove_file, File};
|
use std::fs::{remove_file, File};
|
||||||
use std::io::{Error, Write};
|
use std::io::{Error, Write};
|
||||||
@ -96,11 +97,17 @@ fn main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if !app_args.no_context {
|
if !app_args.no_context {
|
||||||
|
// Safe to unwrap: We just put this through an HTTP request
|
||||||
|
let mut clean_url = Url::parse(&final_url).unwrap();
|
||||||
|
clean_url.set_fragment(None);
|
||||||
|
// Safe to unwrap: must have a protocol and thus base 'cause we just used it.
|
||||||
|
clean_url.set_password(None).unwrap();
|
||||||
|
clean_url.set_username("").unwrap();
|
||||||
html.insert_str(
|
html.insert_str(
|
||||||
0,
|
0,
|
||||||
&format!(
|
&format!(
|
||||||
"<!--- Downloaded from {} on {}using {} v{} -->\n",
|
"<!--- Downloaded from {} on {}using {} v{} -->\n",
|
||||||
&final_url,
|
&clean_url,
|
||||||
downloaded_time.rfc822(),
|
downloaded_time.rfc822(),
|
||||||
env!("CARGO_PKG_NAME"),
|
env!("CARGO_PKG_NAME"),
|
||||||
env!("CARGO_PKG_VERSION"),
|
env!("CARGO_PKG_VERSION"),
|
||||||
|
Loading…
Reference in New Issue
Block a user