Don't download HTML pages attached by GNU Social
This commit is contained in:
parent
10c38400e4
commit
fcb6554ebb
2 changed files with 16 additions and 1 deletions
|
@ -32,6 +32,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Don't ignore `Delete(Person)` verification errors if database error subtype is not `NotFound`.
|
- Don't ignore `Delete(Person)` verification errors if database error subtype is not `NotFound`.
|
||||||
- Don't stop activity processing on invalid local mentions.
|
- Don't stop activity processing on invalid local mentions.
|
||||||
- Accept actor objects where `attachment` property value is not an array.
|
- Accept actor objects where `attachment` property value is not an array.
|
||||||
|
- Don't download HTML pages attached by GNU Social.
|
||||||
|
|
||||||
## [1.9.0] - 2023-01-08
|
## [1.9.0] - 2023-01-08
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,20 @@ fn get_note_visibility(
|
||||||
|
|
||||||
const ATTACHMENT_MAX_SIZE: u64 = 20 * 1000 * 1000;
|
const ATTACHMENT_MAX_SIZE: u64 = 20 * 1000 * 1000;
|
||||||
|
|
||||||
|
fn is_gnu_social_link(author_id: &str, attachment: &Attachment) -> bool {
|
||||||
|
if !author_id.contains("/index.php/user/") {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
if attachment.attachment_type != DOCUMENT {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
match attachment.media_type.as_ref() {
|
||||||
|
None => true,
|
||||||
|
Some(media_type) if media_type.contains("text/html") => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn handle_note(
|
pub async fn handle_note(
|
||||||
db_client: &mut impl GenericClient,
|
db_client: &mut impl GenericClient,
|
||||||
instance: &Instance,
|
instance: &Instance,
|
||||||
|
@ -190,7 +204,7 @@ pub async fn handle_note(
|
||||||
continue;
|
continue;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
if attachment.media_type.as_deref() == Some("text/html; charset=UTF-8") {
|
if is_gnu_social_link(&author_id, &attachment) {
|
||||||
// Don't fetch HTML pages attached by GNU Social
|
// Don't fetch HTML pages attached by GNU Social
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue