Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix overflow when processing punycode encoded URLs like xn--55555577
  • Loading branch information
Byron committed Jun 16, 2024
commit d40d472867b63db6544ca560475bf8e4aad2f5f1
2 changes: 1 addition & 1 deletion idna/src/punycode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ impl Decoder {
if C::EXTERNAL_CALLER && (digit > (u32::MAX - i) / weight) {
return Err(()); // Overflow
}
i += digit * weight;
i = i.checked_add(digit * weight).ok_or(())?;
let t = if k <= bias {
T_MIN
} else if k >= bias + T_MAX {
Expand Down
2 changes: 1 addition & 1 deletion idna/tests/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn test_punycode_prefix_without_length_check() {
#[test]
fn test_punycode_invalid_encoding() {
let config = idna::Config::default();
assert_eq!(config.to_ascii("xn--55555577").unwrap_err().to_string(), "Errors { punycode }");
assert!(config.to_ascii("xn--55555577").is_err());
}

// http://www.unicode.org/reports/tr46/#Table_Example_Processing
Expand Down