mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
bump base64 from 0.10 to 0.21 (#29804)
* bump base64 from 0.10 to 0.21 * Fix configuration of bitflags --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
ad0fa77456
commit
4c8db6af87
10 changed files with 103 additions and 86 deletions
|
@ -77,7 +77,7 @@ use crate::webdriver_handlers::jsval_to_webdriver;
|
|||
use crate::window_named_properties;
|
||||
use app_units::Au;
|
||||
use backtrace::Backtrace;
|
||||
use base64;
|
||||
use base64::Engine;
|
||||
use bluetooth_traits::BluetoothRequest;
|
||||
use canvas_traits::webgl::WebGLChan;
|
||||
use crossbeam_channel::{unbounded, Sender, TryRecvError};
|
||||
|
@ -577,7 +577,10 @@ pub fn base64_btoa(input: DOMString) -> Fallible<DOMString> {
|
|||
|
||||
// "and then must apply the base64 algorithm to that sequence of
|
||||
// octets, and return the result. [RFC4648]"
|
||||
Ok(DOMString::from(base64::encode(&octets)))
|
||||
let config =
|
||||
base64::engine::general_purpose::GeneralPurposeConfig::new().with_encode_padding(true);
|
||||
let engine = base64::engine::GeneralPurpose::new(&base64::alphabet::STANDARD, config);
|
||||
Ok(DOMString::from(engine.encode(&octets)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -624,8 +627,12 @@ pub fn base64_atob(input: DOMString) -> Fallible<DOMString> {
|
|||
return Err(Error::InvalidCharacter);
|
||||
}
|
||||
|
||||
let data = base64::decode_config(&input, base64::STANDARD.decode_allow_trailing_bits(true))
|
||||
.map_err(|_| Error::InvalidCharacter)?;
|
||||
let config = base64::engine::general_purpose::GeneralPurposeConfig::new()
|
||||
.with_decode_padding_mode(base64::engine::DecodePaddingMode::RequireNone)
|
||||
.with_decode_allow_trailing_bits(true);
|
||||
let engine = base64::engine::GeneralPurpose::new(&base64::alphabet::STANDARD, config);
|
||||
|
||||
let data = engine.decode(&input).map_err(|_| Error::InvalidCharacter)?;
|
||||
Ok(data.iter().map(|&b| b as char).collect::<String>().into())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue