Backed out changeset 96753184f3c4 (bug 1604750) for Linting failure in /browserscope/lib/richtext2/richtext2/handlers.py. CLOSED TREE

This commit is contained in:
Dorel Luca 2020-01-13 11:28:57 +02:00
parent 6554cbf4e8
commit 7bd74cb4f0
7 changed files with 37 additions and 64 deletions

20
Cargo.lock generated
View File

@ -452,7 +452,7 @@ name = "chardetng"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"encoding_rs 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -462,7 +462,7 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"chardetng 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding_rs 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1033,7 +1033,7 @@ name = "encoding_c"
version = "0.9.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"encoding_rs 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1041,21 +1041,21 @@ name = "encoding_c_mem"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"encoding_rs 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "encoding_glue"
version = "0.1.0"
dependencies = [
"encoding_rs 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)",
"nserror 0.1.0",
"nsstring 0.1.0",
]
[[package]]
name = "encoding_rs"
version = "0.8.22"
version = "0.8.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2523,7 +2523,7 @@ name = "nsstring"
version = "0.1.0"
dependencies = [
"bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding_rs 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -3538,7 +3538,7 @@ name = "shift_or_euc"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"encoding_rs 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -3547,7 +3547,7 @@ name = "shift_or_euc_c"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"encoding_rs 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)",
"shift_or_euc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -4730,7 +4730,7 @@ dependencies = [
"checksum either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18785c1ba806c258137c937e44ada9ee7e69a37e3c72077542cd2f069d78562a"
"checksum encoding_c 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1891d977f814fd638c3b964987778665b5d1dc8690f46c4c7adc91466ad1c78a"
"checksum encoding_c_mem 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2d32d28c32ff61236b8ea2678c6e43e63bf9690122cb53e9eca7dcefcc4ccb0c"
"checksum encoding_rs 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)" = "cd8d03faa7fe0c1431609dfad7bbe827af30f82e1e2ae6f7ee4fca6bd764bc28"
"checksum encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)" = "87240518927716f79692c2ed85bfe6e98196d18c6401ec75355760233a7e12e9"
"checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3"
"checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3"
"checksum euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2c4786521fec183792e755bf32cd0188e4e7628c6d0fcfd51426435b9081a106"

File diff suppressed because one or more lines are too long

View File

@ -12,7 +12,7 @@
[package]
name = "encoding_rs"
version = "0.8.22"
version = "0.8.20"
authors = ["Henri Sivonen <hsivonen@hsivonen.fi>"]
description = "A Gecko-oriented implementation of the Encoding Standard"
homepage = "https://docs.rs/encoding_rs/"

View File

@ -417,14 +417,6 @@ To regenerate the generated code:
## Release Notes
## 0.8.22
* Formatting fix and new unit test. (No features or bug fixes.)
## 0.8.21
* Fixed a panic with invalid UTF-16[BE|LE] input at the end of the stream.
### 0.8.20
* Make `Decoder::latin1_byte_compatible_up_to` return `None` in more

View File

@ -11,7 +11,7 @@
feature = "cargo-clippy",
allow(doc_markdown, inline_always, new_ret_no_self)
)]
#![doc(html_root_url = "https://docs.rs/encoding_rs/0.8.22")]
#![doc(html_root_url = "https://docs.rs/encoding_rs/0.8.20")]
//! encoding_rs is a Gecko-oriented Free Software / Open Source implementation
//! of the [Encoding Standard](https://encoding.spec.whatwg.org/) in Rust.
@ -4213,7 +4213,7 @@ impl Decoder {
/// bytes taking into account the state of the decoder.
///
/// Returns `None` if the decoder is not in a neutral state, including waiting
/// for the BOM, or if the encoding is never Latin1-byte-compatible.
/// for the BOM or if the encoding is never Latin-byte-compatible.
///
/// Otherwise returns the index of the first byte whose unsigned value doesn't
/// directly correspond to the decoded Unicode scalar value, or the length
@ -5608,19 +5608,6 @@ mod tests {
}
}
#[test]
fn test_buffer_end_utf16be() {
let mut decoder = UTF_16BE.new_decoder_without_bom_handling();
let mut dest = [0u8; 4];
assert_eq!(
decoder.decode_to_utf8(&[0xD8, 0x00], &mut dest, false),
(CoderResult::InputEmpty, 2, 0, false)
);
let _ = decoder.decode_to_utf8(&[0xD8, 0x00], &mut dest, true);
}
#[test]
fn test_hash() {
let mut encodings = ::std::collections::HashSet::new();

View File

@ -90,40 +90,25 @@ impl Utf16Decoder {
},
{
debug_assert!(!self.pending_bmp);
if self.lead_surrogate != 0 || self.lead_byte.is_some() {
// We need to check space without intent to write in order to
// make sure that there is space for the replacement character.
match dest.check_space_bmp() {
Space::Full(_) => {
return (DecoderResult::OutputFull, 0, 0);
if self.lead_surrogate != 0 {
self.lead_surrogate = 0;
match self.lead_byte {
None => {
return (DecoderResult::Malformed(2, 0), src_consumed, dest.written());
}
Space::Available(_) => {
if self.lead_surrogate != 0 {
self.lead_surrogate = 0;
match self.lead_byte {
None => {
return (
DecoderResult::Malformed(2, 0),
src_consumed,
dest.written(),
);
}
Some(_) => {
self.lead_byte = None;
return (
DecoderResult::Malformed(3, 0),
src_consumed,
dest.written(),
);
}
}
}
debug_assert!(self.lead_byte.is_some());
Some(_) => {
self.lead_byte = None;
return (DecoderResult::Malformed(1, 0), src_consumed, dest.written());
return (DecoderResult::Malformed(3, 0), src_consumed, dest.written());
}
}
}
match self.lead_byte {
None => {}
Some(_) => {
self.lead_byte = None;
return (DecoderResult::Malformed(1, 0), src_consumed, dest.written());
}
}
},
{
match self.lead_byte {

View File

@ -68,6 +68,9 @@ pub static UTF8_DATA: Utf8Data = Utf8Data {
// END GENERATED CODE
pub fn utf8_valid_up_to(src: &[u8]) -> usize {
// This algorithm differs from the UTF-8 validation algorithm, but making
// this one consistent with that one makes this slower for reasons I don't
// understand.
let mut read = 0;
'outer: loop {
let mut byte = {
@ -93,6 +96,9 @@ pub fn utf8_valid_up_to(src: &[u8]) -> usize {
// At this point, `byte` is not included in `read`, because we
// don't yet know that a) the UTF-8 sequence is valid and b) that there
// is output space if it is an astral sequence.
// We know, thanks to `ascii_to_basic_latin` that there is output
// space for at least one UTF-16 code unit, so no need to check
// for output space in the BMP cases.
// Inspecting the lead byte directly is faster than what the
// std lib does!
if unsafe { likely(in_inclusive_range8(byte, 0xC2, 0xDF)) } {
@ -230,6 +236,9 @@ pub fn utf8_valid_up_to(src: &[u8]) -> usize {
#[cfg_attr(feature = "cargo-clippy", allow(never_loop, cyclomatic_complexity))]
pub fn convert_utf8_to_utf16_up_to_invalid(src: &[u8], dst: &mut [u16]) -> (usize, usize) {
// This algorithm differs from the UTF-8 validation algorithm, but making
// this one consistent with that one makes this slower for reasons I don't
// understand.
let mut read = 0;
let mut written = 0;
'outer: loop {