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

offset logic bug? let offset = base64.find(',').unwrap_or(base64.len()) + 1; #7

Open
laris opened this issue Feb 10, 2022 · 0 comments

Comments

@laris
Copy link

laris commented Feb 10, 2022

pub fn from_base64(base64: String) -> Vec<u8> {
let offset = base64.find(',').unwrap_or(base64.len())+1;
let mut value = base64;
value.drain(..offset);
return value.from_base64().unwrap();
}

If base64 can get ','
offset = location of ',' +1
drain the header "data:image/jpeg;base64,"
else base64 don't contain ',' (only have base64 data)
offset = base64 length +1
drain will purge the data
endif

if no ',' the offset should set to 0 to avoid drain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant