Skip to content

Commit be685e1

Browse files
committed
Merge master.
2 parents e2ebbf0 + 8a1e3e2 commit be685e1

File tree

18 files changed

+242
-146
lines changed

18 files changed

+242
-146
lines changed

.github/dependabot.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "cargo"
4+
directory: "/"
5+
schedule:
6+
interval: "monthly"
7+
open-pull-requests-limit: 10
8+
- package-ecosystem: "docker"
9+
directory: "/"
10+
schedule:
11+
interval: "monthly"
12+
- package-ecosystem: "github-actions"
13+
directory: "/"
14+
schedule:
15+
interval: "monthly"

.github/workflows/codecov.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ jobs:
99
coverage:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v3
12+
- uses: actions/checkout@v4
1313
- uses: dtolnay/rust-toolchain@stable
1414
- uses: taiki-e/install-action@v2
1515
with:
1616
tool: cargo-tarpaulin
1717
- run: cargo tarpaulin --out Xml
18-
- uses: codecov/codecov-action@v3
18+
- uses: codecov/codecov-action@v4
1919
# A codecov token is not needed for public repos if the repo is linked
2020
# on codecov.io. See https://docs.codecov.com/docs/frequently-asked-questions#where-is-the-repository-upload-token-found
21-
- uses: actions/upload-artifact@v2
21+
- uses: actions/upload-artifact@v4
2222
with:
2323
name: code-coverage-report
2424
path: cobertura.xml

.github/workflows/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
runs-on: ${{ matrix.os }}
3232

3333
steps:
34-
- uses: actions/checkout@v3
34+
- uses: actions/checkout@v4
3535
- uses: dtolnay/rust-toolchain@master
3636
with:
3737
toolchain: ${{ matrix.rust }}
@@ -55,7 +55,7 @@ jobs:
5555
WASM:
5656
runs-on: ubuntu-latest
5757
steps:
58-
- uses: actions/checkout@v3
58+
- uses: actions/checkout@v4
5959
- uses: dtolnay/rust-toolchain@stable
6060
with:
6161
targets: wasm32-unknown-unknown
@@ -64,7 +64,7 @@ jobs:
6464
Lint:
6565
runs-on: ubuntu-latest
6666
steps:
67-
- uses: actions/checkout@v3
67+
- uses: actions/checkout@v4
6868
- uses: dtolnay/rust-toolchain@stable
6969
with:
7070
components: rustfmt, clippy
@@ -75,7 +75,7 @@ jobs:
7575
Audit:
7676
runs-on: ubuntu-latest
7777
steps:
78-
- uses: actions/checkout@v3
78+
- uses: actions/checkout@v4
7979
- uses: EmbarkStudios/cargo-deny-action@v1
8080

8181
Result:

data-url/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "data-url"
3-
version = "0.3.0"
3+
version = "0.3.1"
44
authors = ["Simon Sapin <[email protected]>"]
55
description = "Processing of data: URL according to WHATWG’s Fetch Standard"
66
categories = ["no_std"]

debug_metadata/README.md

Lines changed: 111 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,111 @@
1-
## Debugger Visualizers
2-
3-
Many languages and debuggers enable developers to control how a type is
4-
displayed in a debugger. These are called "debugger visualizations" or "debugger
5-
views".
6-
7-
The Windows debuggers (WinDbg\CDB) support defining custom debugger visualizations using
8-
the `Natvis` framework. To use Natvis, developers write XML documents using the natvis
9-
schema that describe how debugger types should be displayed with the `.natvis` extension.
10-
(See: https://docs.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects?view=vs-2019)
11-
The Natvis files provide patterns which match type names a description of how to display
12-
those types.
13-
14-
The Natvis schema can be found either online (See: https://code.visualstudio.com/docs/cpp/natvis#_schema)
15-
or locally at `<VS Installation Folder>\Xml\Schemas\1033\natvis.xsd`.
16-
17-
The GNU debugger (GDB) supports defining custom debugger views using Pretty Printers.
18-
Pretty printers are written as python scripts that describe how a type should be displayed
19-
when loaded up in GDB/LLDB. (See: https://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing.html#Pretty-Printing)
20-
The pretty printers provide patterns, which match type names, and for matching
21-
types, descibe how to display those types. (For writing a pretty printer, see: https://sourceware.org/gdb/onlinedocs/gdb/Writing-a-Pretty_002dPrinter.html#Writing-a-Pretty_002dPrinter).
22-
23-
### Embedding Visualizers
24-
25-
Through the use of the `#[debugger_visualizer]` attribute, the `url` crate can embed
26-
debugger visualizers into the crate metadata.
27-
28-
Currently the two types of visualizers supported are Natvis and Pretty printers.
29-
30-
For Natvis files, when linking an executable with a crate that includes Natvis files,
31-
the MSVC linker will embed the contents of all Natvis files into the generated `PDB`.
32-
33-
For pretty printers, the compiler will encode the contents of the pretty printer
34-
in the `.debug_gdb_scripts` section of the `ELF` generated.
35-
36-
### Testing Visualizers
37-
38-
The `url` crate supports testing debugger visualizers defined for this crate. The entry point for
39-
these tests are `tests/debugger_visualizer.rs`. These tests are defined using the `debugger_test` and
40-
`debugger_test_parser` crates. The `debugger_test` crate is a proc macro crate which defines a
41-
single proc macro attribute, `#[debugger_test]`. For more detailed information about this crate,
42-
see https://crates.io/crates/debugger_test. The CI pipeline for the `url` crate has been updated
43-
to run the debugger visualizer tests to ensure debugger visualizers do not become broken/stale.
44-
45-
The `#[debugger_test]` proc macro attribute may only be used on test functions and will run the
46-
function under the debugger specified by the `debugger` meta item.
47-
48-
This proc macro attribute has 3 required values:
49-
50-
1. The first required meta item, `debugger`, takes a string value which specifies the debugger to launch.
51-
2. The second required meta item, `commands`, takes a string of new line (`\n`) separated list of debugger
52-
commands to run.
53-
3. The third required meta item, `expected_statements`, takes a string of new line (`\n`) separated list of
54-
statements that must exist in the debugger output. Pattern matching through regular expressions is also
55-
supported by using the `pattern:` prefix for each expected statement.
56-
57-
#### Example:
58-
59-
```rust
60-
#[debugger_test(
61-
debugger = "cdb",
62-
commands = "command1\ncommand2\ncommand3",
63-
expected_statements = "statement1\nstatement2\nstatement3")]
64-
fn test() {
65-
66-
}
67-
```
68-
69-
Using a multiline string is also supported, with a single debugger command/expected statement per line:
70-
71-
```rust
72-
#[debugger_test(
73-
debugger = "cdb",
74-
commands = "
75-
command1
76-
command2
77-
command3",
78-
expected_statements = "
79-
statement1
80-
pattern:statement[0-9]+
81-
statement3")]
82-
fn test() {
83-
84-
}
85-
```
86-
87-
In the example above, the second expected statement uses pattern matching through a regular expression
88-
by using the `pattern:` prefix.
89-
90-
#### Testing Locally
91-
92-
Currently, only Natvis visualizations have been defined for the `url` crate via `debug_metadata/url.natvis`,
93-
which means the `tests/debugger_visualizer.rs` tests need to be run on Windows using the `*-pc-windows-msvc` targets.
94-
To run these tests locally, first ensure the debugging tools for Windows are installed or install them following
95-
the steps listed here, [Debugging Tools for Windows](https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/).
96-
Once the debugging tools have been installed, the tests can be run in the same manner as they are in the CI
97-
pipeline.
98-
99-
#### Note
100-
101-
When running the debugger visualizer tests, `tests/debugger_visualizer.rs`, they need to be run consecutively
102-
and not in parallel. This can be achieved by passing the flag `--test-threads=1` to rustc. This is due to
103-
how the debugger tests are run. Each test marked with the `#[debugger_test]` attribute launches a debugger
104-
and attaches it to the current test process. If tests are running in parallel, the test will try to attach
105-
a debugger to the current process which may already have a debugger attached causing the test to fail.
106-
107-
For example:
108-
109-
```
110-
cargo test --test debugger_visualizer --features debugger_visualizer -- --test-threads=1
111-
```
1+
## Debugger Visualizers
2+
3+
Many languages and debuggers enable developers to control how a type is
4+
displayed in a debugger. These are called "debugger visualizations" or "debugger
5+
views".
6+
7+
The Windows debuggers (WinDbg\CDB) support defining custom debugger visualizations using
8+
the `Natvis` framework. To use Natvis, developers write XML documents using the natvis
9+
schema that describe how debugger types should be displayed with the `.natvis` extension.
10+
(See: https://docs.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects?view=vs-2019)
11+
The Natvis files provide patterns which match type names a description of how to display
12+
those types.
13+
14+
The Natvis schema can be found either online (See: https://code.visualstudio.com/docs/cpp/natvis#_schema)
15+
or locally at `<VS Installation Folder>\Xml\Schemas\1033\natvis.xsd`.
16+
17+
The GNU debugger (GDB) supports defining custom debugger views using Pretty Printers.
18+
Pretty printers are written as python scripts that describe how a type should be displayed
19+
when loaded up in GDB/LLDB. (See: https://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing.html#Pretty-Printing)
20+
The pretty printers provide patterns, which match type names, and for matching
21+
types, descibe how to display those types. (For writing a pretty printer, see: https://sourceware.org/gdb/onlinedocs/gdb/Writing-a-Pretty_002dPrinter.html#Writing-a-Pretty_002dPrinter).
22+
23+
### Embedding Visualizers
24+
25+
Through the use of the `#[debugger_visualizer]` attribute, the `url` crate can embed
26+
debugger visualizers into the crate metadata.
27+
28+
Currently the two types of visualizers supported are Natvis and Pretty printers.
29+
30+
For Natvis files, when linking an executable with a crate that includes Natvis files,
31+
the MSVC linker will embed the contents of all Natvis files into the generated `PDB`.
32+
33+
For pretty printers, the compiler will encode the contents of the pretty printer
34+
in the `.debug_gdb_scripts` section of the `ELF` generated.
35+
36+
### Testing Visualizers
37+
38+
The `url` crate supports testing debugger visualizers defined for this crate. The entry point for
39+
these tests are `tests/debugger_visualizer.rs`. These tests are defined using the `debugger_test` and
40+
`debugger_test_parser` crates. The `debugger_test` crate is a proc macro crate which defines a
41+
single proc macro attribute, `#[debugger_test]`. For more detailed information about this crate,
42+
see https://crates.io/crates/debugger_test. The CI pipeline for the `url` crate has been updated
43+
to run the debugger visualizer tests to ensure debugger visualizers do not become broken/stale.
44+
45+
The `#[debugger_test]` proc macro attribute may only be used on test functions and will run the
46+
function under the debugger specified by the `debugger` meta item.
47+
48+
This proc macro attribute has 3 required values:
49+
50+
1. The first required meta item, `debugger`, takes a string value which specifies the debugger to launch.
51+
2. The second required meta item, `commands`, takes a string of new line (`\n`) separated list of debugger
52+
commands to run.
53+
3. The third required meta item, `expected_statements`, takes a string of new line (`\n`) separated list of
54+
statements that must exist in the debugger output. Pattern matching through regular expressions is also
55+
supported by using the `pattern:` prefix for each expected statement.
56+
57+
#### Example:
58+
59+
```rust
60+
#[debugger_test(
61+
debugger = "cdb",
62+
commands = "command1\ncommand2\ncommand3",
63+
expected_statements = "statement1\nstatement2\nstatement3")]
64+
fn test() {
65+
66+
}
67+
```
68+
69+
Using a multiline string is also supported, with a single debugger command/expected statement per line:
70+
71+
```rust
72+
#[debugger_test(
73+
debugger = "cdb",
74+
commands = "
75+
command1
76+
command2
77+
command3",
78+
expected_statements = "
79+
statement1
80+
pattern:statement[0-9]+
81+
statement3")]
82+
fn test() {
83+
84+
}
85+
```
86+
87+
In the example above, the second expected statement uses pattern matching through a regular expression
88+
by using the `pattern:` prefix.
89+
90+
#### Testing Locally
91+
92+
Currently, only Natvis visualizations have been defined for the `url` crate via `debug_metadata/url.natvis`,
93+
which means the `tests/debugger_visualizer.rs` tests need to be run on Windows using the `*-pc-windows-msvc` targets.
94+
To run these tests locally, first ensure the debugging tools for Windows are installed or install them following
95+
the steps listed here, [Debugging Tools for Windows](https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/).
96+
Once the debugging tools have been installed, the tests can be run in the same manner as they are in the CI
97+
pipeline.
98+
99+
#### Note
100+
101+
When running the debugger visualizer tests, `tests/debugger_visualizer.rs`, they need to be run consecutively
102+
and not in parallel. This can be achieved by passing the flag `--test-threads=1` to rustc. This is due to
103+
how the debugger tests are run. Each test marked with the `#[debugger_test]` attribute launches a debugger
104+
and attaches it to the current test process. If tests are running in parallel, the test will try to attach
105+
a debugger to the current process which may already have a debugger attached causing the test to fail.
106+
107+
For example:
108+
109+
```
110+
cargo test --test debugger_visualizer --features debugger_visualizer -- --test-threads=1
111+
```

form_urlencoded/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "form_urlencoded"
3-
version = "1.2.0"
3+
version = "1.2.1"
44
authors = ["The rust-url developers"]
55
description = "Parser and serializer for the application/x-www-form-urlencoded syntax, as used by HTML forms."
66
categories = ["no_std"]

idna/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "idna"
3-
version = "0.4.0"
3+
version = "0.5.0"
44
authors = ["The rust-url developers"]
55
description = "IDNA (Internationalizing Domain Names in Applications) and Punycode."
66
categories = ["no_std"]

idna/src/punycode.rs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ fn adapt(mut delta: u32, num_points: u32, first_time: bool) -> u32 {
4141

4242
/// Convert Punycode to an Unicode `String`.
4343
///
44-
/// This is a convenience wrapper around `decode`.
44+
/// Return None on malformed input or overflow.
45+
/// Overflow can only happen on inputs that take more than
46+
/// 63 encoded bytes, the DNS limit on domain name labels.
4547
#[inline]
4648
pub fn decode_to_string(input: &str) -> Option<String> {
47-
decode(input).map(|chars| chars.into_iter().collect())
49+
Some(Decoder::default().decode(input).ok()?.collect())
4850
}
4951

5052
/// Convert Punycode to Unicode.
@@ -215,6 +217,9 @@ impl<'a> ExactSizeIterator for Decode<'a> {
215217
/// This is a convenience wrapper around `encode`.
216218
#[inline]
217219
pub fn encode_str(input: &str) -> Option<String> {
220+
if input.len() > u32::MAX as usize {
221+
return None;
222+
}
218223
let mut buf = String::with_capacity(input.len());
219224
encode_into(input.chars(), &mut buf).ok().map(|()| buf)
220225
}
@@ -224,6 +229,9 @@ pub fn encode_str(input: &str) -> Option<String> {
224229
/// Return None on overflow, which can only happen on inputs that would take more than
225230
/// 63 encoded bytes, the DNS limit on domain name labels.
226231
pub fn encode(input: &[char]) -> Option<String> {
232+
if input.len() > u32::MAX as usize {
233+
return None;
234+
}
227235
let mut buf = String::with_capacity(input.len());
228236
encode_into(input.iter().copied(), &mut buf)
229237
.ok()
@@ -235,9 +243,9 @@ where
235243
I: Iterator<Item = char> + Clone,
236244
{
237245
// Handle "basic" (ASCII) code points. They are encoded as-is.
238-
let (mut input_length, mut basic_length) = (0, 0);
246+
let (mut input_length, mut basic_length) = (0u32, 0);
239247
for c in input.clone() {
240-
input_length += 1;
248+
input_length = input_length.checked_add(1).ok_or(())?;
241249
if c.is_ascii() {
242250
output.push(c);
243251
basic_length += 1;
@@ -269,10 +277,7 @@ where
269277
for c in input.clone() {
270278
let c = c as u32;
271279
if c < code_point {
272-
delta += 1;
273-
if delta == 0 {
274-
return Err(()); // Overflow
275-
}
280+
delta = delta.checked_add(1).ok_or(())?;
276281
}
277282
if c == code_point {
278283
// Represent delta as a generalized variable-length integer:
@@ -314,3 +319,12 @@ fn value_to_digit(value: u32) -> char {
314319
_ => panic!(),
315320
}
316321
}
322+
323+
#[test]
324+
#[ignore = "slow"]
325+
#[cfg(target_pointer_width = "64")]
326+
fn huge_encode() {
327+
let mut buf = String::new();
328+
assert!(encode_into(std::iter::repeat('ß').take(u32::MAX as usize + 1), &mut buf).is_err());
329+
assert_eq!(buf.len(), 0);
330+
}

idna/src/uts46.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ impl Idna {
509509
}
510510

511511
#[derive(Clone, Copy)]
512+
#[must_use]
512513
pub struct Config {
513514
use_std3_ascii_rules: bool,
514515
transitional_processing: bool,

0 commit comments

Comments
 (0)