Skip to content
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

Replace base64 with data-encoding #263

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ include = ["src", "Cargo.toml", "LICENSE-APACHE", "LICENSE-MIT", "benches",

[dependencies]
# Vorbis comments pictures
base64 = "0.21.4"
data-encoding = "2.4.0"
byteorder = "1.4.3"
# ID3 compressed frames
flate2 = { version = "1.0.27", optional = true }
Expand Down
4 changes: 2 additions & 2 deletions src/ogg/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::probe::ParsingMode;
use std::borrow::Cow;
use std::io::{Read, Seek, SeekFrom};

use base64::Engine;
use byteorder::{LittleEndian, ReadBytesExt};
use data_encoding::BASE64;
use ogg_pager::{Packets, PageHeader};

pub type OGGTags = (Option<VorbisComments>, PageHeader, Packets);
Expand Down Expand Up @@ -111,7 +111,7 @@ where
// to a `METADATA_BLOCK_PICTURE` for it to be useful.
//
// <https://wiki.xiph.org/VorbisComment#Conversion_to_METADATA_BLOCK_PICTURE>
let picture_data = base64::engine::general_purpose::STANDARD.decode(value);
let picture_data = BASE64.decode(value);

match picture_data {
Ok(picture_data) => {
Expand Down
8 changes: 3 additions & 5 deletions src/picture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use std::borrow::Cow;
use std::fmt::{Debug, Formatter};
use std::io::{Cursor, Read, Seek, SeekFrom};

use base64::Engine as _;
use byteorder::{BigEndian, ReadBytesExt};
use data_encoding::BASE64;

/// Common picture item keys for APE
pub const APE_PICTURE_TYPES: [&str; 21] = [
Expand Down Expand Up @@ -609,9 +609,7 @@ impl Picture {
data.extend(pic_data.iter());

if encode {
base64::engine::general_purpose::STANDARD
.encode(data)
.into_bytes()
BASE64.encode(&data).into_bytes()
} else {
data
}
Expand All @@ -632,7 +630,7 @@ impl Picture {
parse_mode: ParsingMode,
) -> Result<(Self, PictureInformation)> {
if encoded {
let data = base64::engine::general_purpose::STANDARD
let data = BASE64
.decode(bytes)
.map_err(|_| LoftyError::new(ErrorKind::NotAPicture))?;
Self::from_flac_bytes_inner(&data, parse_mode)
Expand Down