Skip to content

Commit 1af73bc

Browse files
authored
Merge pull request #37 from rust-ammonia/release-0.5.1
Release 0.5.1
2 parents 7129c42 + 32d8089 commit 1af73bc

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "content-security-policy"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
authors = ["Michael Howell <[email protected]>"]
55
description = "Will parse and validate Content-Security-Policy level 3"
66
keywords = ["http", "csp", "security"]
@@ -20,7 +20,7 @@ exclude = [
2020
url = "2"
2121
percent-encoding = "2.1"
2222
regex = { version = "1.1", default-features = false, features = ["std"] }
23-
bitflags = "1.3"
23+
bitflags = "2.3"
2424
version-sync = { version = "0.9", optional = true }
2525
serde = { version = "1.0", features = ["derive"], optional = true }
2626
sha2 = "0.10"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ To use `content-security-policy`, add it to your project's `Cargo.toml` file:
1515

1616
```toml
1717
[dependencies]
18-
content-security-policy = "0.5.0"
18+
content-security-policy = "0.5.1"
1919
```
2020

2121
# Example

src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,11 +1510,13 @@ impl HashAlgorithm {
15101510
}
15111511
}
15121512
pub fn apply(self, value: &str) -> String {
1513+
use base64::Engine as _;
15131514
let bytes = value.as_bytes();
1515+
let standard = base64::engine::general_purpose::STANDARD;
15141516
match self {
1515-
HashAlgorithm::Sha256 => base64::encode(sha2::Sha256::digest(bytes)),
1516-
HashAlgorithm::Sha384 => base64::encode(sha2::Sha384::digest(bytes)),
1517-
HashAlgorithm::Sha512 => base64::encode(sha2::Sha512::digest(bytes)),
1517+
HashAlgorithm::Sha256 => standard.encode(sha2::Sha256::digest(bytes)),
1518+
HashAlgorithm::Sha384 => standard.encode(sha2::Sha384::digest(bytes)),
1519+
HashAlgorithm::Sha512 => standard.encode(sha2::Sha512::digest(bytes)),
15181520
}
15191521
}
15201522
}

src/sandboxing_directive.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use bitflags::bitflags;
22

33
bitflags!{
4+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45
pub struct SandboxingFlagSet: u32 {
56
const SANDBOXED_NAVIGATION_BROWSING_CONTEXT_FLAG = 0x00000001;
67
const SANDBOXED_AUXILIARY_NAVIGATION_BROWSING_CONTEXT_FLAG = 0x00000002;

0 commit comments

Comments
 (0)