Skip to content

Rename documentation blacklist to blocklist #1536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/models/krate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ use views::{EncodableCrate, EncodableCrateLinks};
use models::helpers::with_count::*;
use schema::*;

/// Hosts in this blacklist are known to not be hosting documentation,
/// Hosts in this list are known to not be hosting documentation,
/// and are possibly of malicious intent e.g. ad tracking networks, etc.
const DOCUMENTATION_BLACKLIST: [&str; 1] = ["rust-ci.org"];
const DOCUMENTATION_BLOCKLIST: [&str; 1] = ["rust-ci.org"];

#[derive(Debug, Insertable, Queryable, Identifiable, Associations, AsChangeset, Clone, Copy)]
#[belongs_to(Crate)]
Expand Down Expand Up @@ -330,7 +330,7 @@ impl Crate {
let keyword_ids = keywords.map(|kws| kws.iter().map(|kw| kw.keyword.clone()).collect());
let category_ids = categories.map(|cats| cats.iter().map(|cat| cat.slug.clone()).collect());
let badges = badges.map(|bs| bs.into_iter().map(|b| b.encodable()).collect());
let documentation = Crate::remove_blacklisted_documentation_urls(documentation);
let documentation = Crate::remove_blocked_documentation_urls(documentation);

EncodableCrate {
id: name.clone(),
Expand Down Expand Up @@ -360,8 +360,8 @@ impl Crate {
}
}

/// Return `None` if the documentation URL host matches a blacklisted host
fn remove_blacklisted_documentation_urls(url: Option<String>) -> Option<String> {
/// Return `None` if the documentation URL host matches a blocked host
fn remove_blocked_documentation_urls(url: Option<String>) -> Option<String> {
// Handles if documentation URL is None
let url = match url {
Some(url) => url,
Expand All @@ -380,8 +380,8 @@ impl Crate {
None => return None,
};

// Match documentation URL host against blacklisted host array elements
if DOCUMENTATION_BLACKLIST.contains(&url_host) {
// Match documentation URL host against blocked host array elements
if DOCUMENTATION_BLOCKLIST.contains(&url_host) {
None
} else {
Some(url)
Expand Down Expand Up @@ -520,32 +520,32 @@ mod tests {
use models::Crate;

#[test]
fn documentation_blacklist_no_url_provided() {
assert_eq!(Crate::remove_blacklisted_documentation_urls(None), None);
fn documentation_blocked_no_url_provided() {
assert_eq!(Crate::remove_blocked_documentation_urls(None), None);
}

#[test]
fn documentation_blacklist_invalid_url() {
fn documentation_blocked_invalid_url() {
assert_eq!(
Crate::remove_blacklisted_documentation_urls(Some(String::from("not a url"))),
Crate::remove_blocked_documentation_urls(Some(String::from("not a url"))),
None
);
}

#[test]
fn documentation_blacklist_url_contains_partial_match() {
fn documentation_blocked_url_contains_partial_match() {
assert_eq!(
Crate::remove_blacklisted_documentation_urls(Some(String::from(
Crate::remove_blocked_documentation_urls(Some(String::from(
"http://rust-ci.organists.com"
)),),
Some(String::from("http://rust-ci.organists.com"))
);
}

#[test]
fn documentation_blacklist_blacklisted_url() {
fn documentation_blocked_url() {
assert_eq!(
Crate::remove_blacklisted_documentation_urls(Some(String::from(
Crate::remove_blocked_documentation_urls(Some(String::from(
"http://rust-ci.org/crate/crate-0.1/doc/crate-0.1",
),),),
None
Expand Down
2 changes: 1 addition & 1 deletion src/tests/krate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ fn test_default_sort_recent() {
}

#[test]
fn block_blacklisted_documentation_url() {
fn block_bad_documentation_url() {
let (_b, app, middle) = app();

let _ = {
Expand Down