Bug 1836658 - Update cssparser to 0.31.2. r=emilio,supply-chain-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D180906
This commit is contained in:
Mike Hommey 2023-06-14 20:50:14 +00:00
parent 3f029c94c7
commit 460db62e52
13 changed files with 69 additions and 141 deletions

13
Cargo.lock generated
View File

@ -1021,24 +1021,25 @@ dependencies = [
[[package]]
name = "cssparser"
version = "0.31.0"
version = "0.31.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b3df4f93e5fbbe73ec01ec8d3f68bba73107993a5b1e7519273c32db9b0d5be"
dependencies = [
"cssparser-macros",
"dtoa-short",
"itoa",
"phf",
"proc-macro2",
"quote",
"smallvec",
"syn 1.0.107",
]
[[package]]
name = "cssparser-macros"
version = "0.6.0"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331"
dependencies = [
"quote",
"syn 1.0.107",
"syn 2.0.18",
]
[[package]]

View File

@ -158,12 +158,6 @@ moz_asserts = { path = "mozglue/static/rust/moz_asserts" }
# Workaround for https://github.com/rust-lang/cargo/issues/11232
rure = { path = "third_party/rust/rure" }
# 0.31.1 but without rust-cssparser#342.
# TODO: Remove these, and just use v0.31.1 once bug 1836219 lands
# (which will get syn 2 into the tree).
cssparser = { path = "third_party/rust/cssparser" }
cssparser-macros = { path = "third_party/rust/cssparser-macros" }
# Other overrides
chardetng = { git = "https://github.com/hsivonen/chardetng", rev="3484d3e3ebdc8931493aa5df4d7ee9360a90e76b" }
chardetng_c = { git = "https://github.com/hsivonen/chardetng_c", rev="ed8a4c6f900a90d4dbc1d64b856e61490a1c3570" }

View File

@ -826,6 +826,11 @@ All the changes in this release were authored by Mozilla staff, except the
uninit_array stuff, which looks fine.
"""
[[audits.cssparser]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
delta = "0.31.0 -> 0.31.2"
[[audits.cssparser-macros]]
who = "Emilio Cobos Álvarez <emilio@crisal.io>"
criteria = "safe-to-deploy"
@ -841,6 +846,11 @@ criteria = "safe-to-deploy"
version = "0.6.0@git:6ce91afdf292c4290118843e7421e146f0a4c48b"
notes = "We are pulling this package from a non crates.io source until the changes are published. No changes were made to the code."
[[audits.cssparser-macros]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
delta = "0.6.0 -> 0.6.1"
[[audits.cstr]]
who = "Emilio Cobos Álvarez <emilio@crisal.io>"
criteria = "safe-to-deploy"

View File

@ -39,14 +39,6 @@ notes = "This is a pinned version of the upstream code, presumably to get a fix
audit-as-crates-io = true
notes = "This is upstream plus a warning fix from bug 1823866."
[policy.cssparser]
audit-as-crates-io = true
notes = "Upstream code plus nesting changes that haven't been published yet authored by us"
[policy.cssparser-macros]
audit-as-crates-io = true
notes = "Needed because this crate lives along cssparser"
[policy.d3d12]
audit-as-crates-io = true
notes = "Unpublished wgpu revisions point to unpublished d3d12 revisions."

View File

@ -1 +1 @@
{"files":{"Cargo.toml":"43dbb4a9920bd25625edb3f1dc7a9bdc856d13113bbe8fe7e04e728c4362603b","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","lib.rs":"0e8f69571d62b9516d4f3158b7c354b1f29de78d82ac2b19977652c0810dbdfa"},"package":null}
{"files":{"Cargo.toml":"d4a43ad31d5048cf19ee80ec38de90fa98b9b9902b97d61e4edc940246806295","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","lib.rs":"10e68d5a92a053ff498cb1caa8290e508f691e32b73222a5a4737ee9a4097ce2"},"package":"13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331"}

View File

@ -12,7 +12,7 @@
[package]
edition = "2018"
name = "cssparser-macros"
version = "0.6.0"
version = "0.6.1"
authors = ["Simon Sapin <simon.sapin@exyr.org>"]
description = "Procedural macros for cssparser"
documentation = "https://docs.rs/cssparser-macros/"
@ -23,11 +23,11 @@ repository = "https://github.com/servo/rust-cssparser"
path = "lib.rs"
proc-macro = true
[dependencies]
quote = "1"
[dependencies.quote]
version = "1"
[dependencies.syn]
version = "1"
version = "2"
features = [
"full",
"extra-traits",

View File

@ -38,14 +38,18 @@ pub fn _cssparser_internal_max_len(input: TokenStream) -> TokenStream {
.into()
}
fn get_byte_from_lit(lit: &syn::Lit) -> u8 {
if let syn::Lit::Byte(ref byte) = *lit {
byte.value()
} else {
panic!("Found a pattern that wasn't a byte")
}
}
fn get_byte_from_expr_lit(expr: &syn::Expr) -> u8 {
match *expr {
syn::Expr::Lit(syn::ExprLit { ref lit, .. }) => {
if let syn::Lit::Byte(ref byte) = *lit {
byte.value()
} else {
panic!("Found a pattern that wasn't a byte")
}
get_byte_from_lit(lit)
}
_ => unreachable!(),
}
@ -59,15 +63,15 @@ fn parse_pat_to_table<'a>(
table: &mut [u8; 256],
) {
match pat {
&syn::Pat::Lit(syn::PatLit { ref expr, .. }) => {
let value = get_byte_from_expr_lit(expr);
&syn::Pat::Lit(syn::PatLit { ref lit, .. }) => {
let value = get_byte_from_lit(lit);
if table[value as usize] == 0 {
table[value as usize] = case_id;
}
}
&syn::Pat::Range(syn::PatRange { ref lo, ref hi, .. }) => {
let lo = get_byte_from_expr_lit(lo);
let hi = get_byte_from_expr_lit(hi);
&syn::Pat::Range(syn::PatRange { ref start, ref end, .. }) => {
let lo = get_byte_from_expr_lit(&start.as_ref().unwrap());
let hi = get_byte_from_expr_lit(&end.as_ref().unwrap());
for value in lo..hi {
if table[value as usize] == 0 {
table[value as usize] = case_id;

View File

@ -1 +1 @@
{"files":{".github/workflows/main.yml":"73c57dbb2c5471de2fcba828e356d09931ae89176f3bb695029b169dbb3f696f","Cargo.toml":"cffe5d5b5b66f65b9e4ca2aee56cf046604075ccfff0a89ca37ef4bb59164d02","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"53a6805edd80f642473514cb93f1f4197e17a911d66a2dfcefc3dc5e82bac206","docs/.nojekyll":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","docs/404.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","docs/index.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","src/color.rs":"df7d97636896df02b7ba56abf6f74f121d8320615f9e6ef6d43e6f272d3600cb","src/cow_rc_str.rs":"22d6829ab54c51486af4bacf5f184a6c95c15febdbbd5630a98b995ed0ee3e55","src/from_bytes.rs":"b1cf15c4e975523fef46b575598737a39f3c63e5ce0b2bfd6ec627c69c6ea54a","src/lib.rs":"d4e37941cfa90e42deb7d0537483ac0b2bac033adf4bb0007b000cd807c588f5","src/macros.rs":"883df01d4a8dfc661b8ffa17fab694ff6fb271e99e9c6b023e73d49bbaa6e5d6","src/nth.rs":"2fc26915f0a36cb22ac45dd9a7ecbdc64c327b2ec135370258ec3db9f9985460","src/parser.rs":"50fa448b316902d5f4aa18725220633c28bb7d82cbaff125177d79d4cf8dae58","src/rules_and_declarations.rs":"cb08533dd4b239a6cbd59d8fcca1447c8089940dd519edea9c9a9b51fa999d49","src/serializer.rs":"3a0155521676deea9a6327c2ed00af6d5dabb29a97e2341d0f565f8c2b66d0a3","src/size_of_tests.rs":"da0cbcaa304f7800e9122e2bce0a11d42a70b9012e646a723cb23ee74a6b858c","src/tests.rs":"6c950841e8c454c50ae439543fa8718f935058a6bb1b1bf77033439daeff08a7","src/tokenizer.rs":"9900460d9bad82b7a41829d01537094203fafc7092c954aac969546ea53d5bba","src/unicode_range.rs":"20d96f06fbb73921e308cc340c9fe065e27f19843005689fb259007a6a372bcc"},"package":null}
{"files":{"Cargo.toml":"040cfbd0b6ddccc9ee3703e5386dda1a52e13c1abdacfa207f502af42364607b","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"53a6805edd80f642473514cb93f1f4197e17a911d66a2dfcefc3dc5e82bac206","docs/404.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","docs/index.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","src/color.rs":"740465ed632940dd9551b92e2ea9140cd9e5e9d3e0f1f548018b98bbff159b6f","src/cow_rc_str.rs":"4d172d3633ef55af815784fbaee03cbcf85796a380765a0af09bbb6ca5b6fbab","src/from_bytes.rs":"b1cf15c4e975523fef46b575598737a39f3c63e5ce0b2bfd6ec627c69c6ea54a","src/lib.rs":"8f1657c507380db0281e5aa7eb06f17d7f559c582b265d6589006042ffad18ad","src/macros.rs":"883df01d4a8dfc661b8ffa17fab694ff6fb271e99e9c6b023e73d49bbaa6e5d6","src/nth.rs":"2fc26915f0a36cb22ac45dd9a7ecbdc64c327b2ec135370258ec3db9f9985460","src/parser.rs":"50fa448b316902d5f4aa18725220633c28bb7d82cbaff125177d79d4cf8dae58","src/rules_and_declarations.rs":"63971fd3dccee82197ecd2e32953bc96fcc2fe43eaa8e1d048d1842d00a5a098","src/serializer.rs":"3a0155521676deea9a6327c2ed00af6d5dabb29a97e2341d0f565f8c2b66d0a3","src/size_of_tests.rs":"da0cbcaa304f7800e9122e2bce0a11d42a70b9012e646a723cb23ee74a6b858c","src/tests.rs":"6c950841e8c454c50ae439543fa8718f935058a6bb1b1bf77033439daeff08a7","src/tokenizer.rs":"9900460d9bad82b7a41829d01537094203fafc7092c954aac969546ea53d5bba","src/unicode_range.rs":"20d96f06fbb73921e308cc340c9fe065e27f19843005689fb259007a6a372bcc"},"package":"5b3df4f93e5fbbe73ec01ec8d3f68bba73107993a5b1e7519273c32db9b0d5be"}

View File

@ -1,63 +0,0 @@
name: CI
on:
push:
branches: [auto]
pull_request:
workflow_dispatch:
jobs:
linux-ci:
name: Linux
runs-on: ubuntu-latest
strategy:
matrix:
toolchain:
- nightly
- beta
- stable
- 1.63.0
features:
-
- --features dummy_match_byte
include:
- toolchain: nightly
features: --features bench
- toolchain: nightly
features: --features bench,dummy_match_byte
steps:
- uses: actions/checkout@v2
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
override: true
- name: Cargo build
run: cargo build ${{ matrix.features }}
- name: Cargo doc
run: cargo doc ${{ matrix.features }}
- name: Cargo test
run: cargo test ${{ matrix.features }}
- name: macros build
run: cargo build
working-directory: macros
build_result:
name: homu build finished
runs-on: ubuntu-latest
needs:
- "linux-ci"
steps:
- name: Mark the job as successful
run: exit 0
if: success()
- name: Mark the job as unsuccessful
run: exit 1
if: "!success()"

View File

@ -13,7 +13,7 @@
edition = "2018"
rust-version = "1.63"
name = "cssparser"
version = "0.31.0"
version = "0.31.2"
authors = ["Simon Sapin <simon.sapin@exyr.org>"]
exclude = [
"src/css-parsing-tests/**",
@ -30,13 +30,14 @@ keywords = [
license = "MPL-2.0"
repository = "https://github.com/servo/rust-cssparser"
[dependencies]
dtoa-short = "0.3"
itoa = "1.0"
smallvec = "1.0"
[dependencies.cssparser-macros]
version = "0.6"
version = "0.6.1"
[dependencies.dtoa-short]
version = "0.3"
[dependencies.itoa]
version = "1.0"
[dependencies.phf]
version = ">=0.8,<=0.11"
@ -46,30 +47,18 @@ features = ["macros"]
version = "1.0"
optional = true
[dev-dependencies]
difference = "2.0"
encoding_rs = "0.8"
serde_json = "1.0"
[dependencies.smallvec]
version = "1.0"
[build-dependencies]
proc-macro2 = "1"
quote = "1"
[dev-dependencies.difference]
version = "2.0"
[build-dependencies.syn]
version = "1"
features = [
"extra-traits",
"fold",
"full",
]
[dev-dependencies.encoding_rs]
version = "0.8"
[dev-dependencies.serde_json]
version = "1.0"
[features]
bench = []
dummy_match_byte = []
[workspace]
members = [
".",
"./macros",
"./procedural-masquerade",
]

View File

@ -9,7 +9,7 @@ use std::f32::consts::PI;
use std::fmt;
use std::str::FromStr;
use super::{ParseError, Parser, ToCss, Token};
use super::{CowRcStr, ParseError, Parser, ToCss, Token};
#[cfg(feature = "serde")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};
@ -26,9 +26,10 @@ where
}
}
/// Serialize the alpha copmonent of a color according to the specification.
/// <https://drafts.csswg.org/css-color-4/#serializing-alpha-values>
#[inline]
fn serialize_alpha(
pub fn serialize_color_alpha(
dest: &mut impl fmt::Write,
alpha: Option<f32>,
legacy_syntax: bool,
@ -146,7 +147,7 @@ impl ToCss for RGBA {
self.blue.unwrap_or(0).to_css(dest)?;
// Legacy syntax does not allow none components.
serialize_alpha(dest, Some(self.alpha.unwrap_or(0.0)), true)?;
serialize_color_alpha(dest, Some(self.alpha.unwrap_or(0.0)), true)?;
dest.write_char(')')
}
@ -367,7 +368,7 @@ macro_rules! impl_lab_like {
serialize_none_or(dest, &self.a)?;
dest.write_char(' ')?;
serialize_none_or(dest, &self.b)?;
serialize_alpha(dest, self.alpha, false)?;
serialize_color_alpha(dest, self.alpha, false)?;
dest.write_char(')')
}
}
@ -458,7 +459,7 @@ macro_rules! impl_lch_like {
serialize_none_or(dest, &self.chroma)?;
dest.write_char(' ')?;
serialize_none_or(dest, &self.hue)?;
serialize_alpha(dest, self.alpha, false)?;
serialize_color_alpha(dest, self.alpha, false)?;
dest.write_char(')')
}
}
@ -584,7 +585,7 @@ impl ToCss for ColorFunction {
dest.write_char(' ')?;
serialize_none_or(dest, &self.c3)?;
serialize_alpha(dest, self.alpha, false)?;
serialize_color_alpha(dest, self.alpha, false)?;
dest.write_char(')')
}
@ -901,7 +902,7 @@ where
Token::Function(ref name) => {
let name = name.clone();
return input.parse_nested_block(|arguments| {
parse_color_function(color_parser, &name, arguments)
parse_color_function(color_parser, name, arguments)
});
}
_ => Err(()),
@ -1209,13 +1210,13 @@ where
#[inline]
fn parse_color_function<'i, 't, P>(
color_parser: &P,
name: &str,
name: CowRcStr<'i>,
arguments: &mut Parser<'i, 't>,
) -> Result<P::Output, ParseError<'i, P::Error>>
where
P: ColorParser<'i>,
{
let color = match_ignore_ascii_case! { name,
let color = match_ignore_ascii_case! { &name,
"rgb" | "rgba" => parse_rgb(color_parser, arguments),
"hsl" | "hsla" => parse_hsl(color_parser, arguments),
@ -1240,7 +1241,7 @@ where
"color" => parse_color_with_color_space(color_parser, arguments),
_ => return Err(arguments.new_unexpected_token_error(Token::Ident(name.to_owned().into()))),
_ => return Err(arguments.new_unexpected_token_error(Token::Ident(name))),
}?;
arguments.expect_exhausted()?;

View File

@ -68,9 +68,9 @@ fn parse_border_spacing(_context: &ParserContext, input: &mut Parser)
#![recursion_limit = "200"] // For color::parse_color_keyword
pub use crate::color::{
hsl_to_rgb, hwb_to_rgb, parse_color_keyword, parse_color_with, parse_hash_color, AngleOrNumber,
Color, ColorFunction, ColorParser, FromParsedColor, Hsl, Hwb, Lab, Lch, NumberOrPercentage,
Oklab, Oklch, PredefinedColorSpace, RGBA,
hsl_to_rgb, hwb_to_rgb, parse_color_keyword, parse_color_with, parse_hash_color,
serialize_color_alpha, AngleOrNumber, Color, ColorFunction, ColorParser, FromParsedColor, Hsl,
Hwb, Lab, Lch, NumberOrPercentage, Oklab, Oklch, PredefinedColorSpace, RGBA,
};
pub use crate::cow_rc_str::CowRcStr;
pub use crate::from_bytes::{stylesheet_encoding, EncodingSupport};
@ -84,7 +84,7 @@ pub use crate::parser::{Delimiter, Delimiters, Parser, ParserInput, ParserState}
pub use crate::rules_and_declarations::{parse_important, parse_one_declaration};
pub use crate::rules_and_declarations::{parse_one_rule, StyleSheetParser};
pub use crate::rules_and_declarations::{AtRuleParser, QualifiedRuleParser};
pub use crate::rules_and_declarations::{RuleBodyParser, RuleBodyItemParser, DeclarationParser};
pub use crate::rules_and_declarations::{DeclarationParser, RuleBodyItemParser, RuleBodyParser};
pub use crate::serializer::{serialize_identifier, serialize_name, serialize_string};
pub use crate::serializer::{CssStringWriter, ToCss, TokenSerializationType};
pub use crate::tokenizer::{SourceLocation, SourcePosition, Token};