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 unmaintained encoding dep with maintained encoding_rs dep #4694

Merged
merged 5 commits into from
May 3, 2024

Conversation

SleeplessOne1917
Copy link
Member

I used cargo-audit to audit our dependencies and found some vulnerabilities. There are some severe vulnerabilities that are from indirect dependencies. I am currently working on this.

In addition to the sever, there are 3 warnings for using unmaintained crates. I couldn't find a crate that did the same thing as safemem, and yaml-rust is an indirect dependency of the latest version of markdown-it. However,, I was able to find a replacement for the encoding crate we use.

I replaced encoding, which hasn't had an update in 7 years with encoding_rs, which was last updated less than a month ago and has about 10 times the all time downloads and 16 times recent downloads compared to the former.

}
if charset != UTF_8.name() {
if let Some(encoding) = Encoding::for_label(charset.as_bytes()) {
page = HTML::from_string(encoding.decode(html_bytes).0.into_owned(), None)?;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to specify to replace malformed sequences because this decode already does that.

From the docs:

Decode complete input to Cow<'a, str> with BOM sniffing and with malformed sequences replaced with the REPLACEMENT CHARACTER when the entire input is available as a single buffer (i.e. the end of the buffer marks the end of the stream).

@SleeplessOne1917 SleeplessOne1917 merged commit 485b0f1 into main May 3, 2024
2 checks passed
@SleeplessOne1917 SleeplessOne1917 deleted the replace-unmaintained-deps branch May 3, 2024 10:42
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

Successfully merging this pull request may close these issues.

None yet

2 participants