Skip to content

Release 1.3.1 - #63

Merged
FlorianRappl merged 24 commits into
mainfrom
devel
Nov 9, 2026
Merged

FlorianRappl merged 24 commits into
mainfrom
devel

Conversation

@FlorianRappl

Copy link
Copy Markdown
Contributor

Types of Changes

Prerequisites

Please make sure you can check the following two boxes:

  • I have read the CONTRIBUTING document
  • My code follows the code style of this project

Contribution Type

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue, please reference the issue id)
  • New feature (non-breaking change which adds functionality, make sure to open an associated issue first)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Description

This pull request introduces version 1.3.1, focusing on improved security and compatibility for the .NET 8 and .NET 10 targets. The most notable changes are the addition of trimming and Native AOT compatibility, stricter validation for cookie expiration dates, and enhanced sanitization of file names extracted from HTTP headers to prevent directory traversal or invalid file names. Several new tests have been added to verify these behaviors.

michaelthyregod and others added 8 commits November 8, 2026 16:16
The date was constructed before its range was checked, so e.g. "31 Feb" threw an
ArgumentOutOfRangeException out of the cookie provider and failed the page load. The
range (including the days of the month) is checked first and the attribute is
ignored, as RFC 6265 section 5.1.1 asks for an invalid date.
- Mark the net8.0 and net10.0 targets IsAotCompatible, so the trim and AOT
  analyzers run on every build, with the same KnownILLinkPack override as
  AngleSharp, AngleSharp.Xml and AngleSharp.Css
- Update AGENTS.md and CHANGELOG.md

The library uses no reflection, so no code changes were needed: all targets
build without trim or AOT warnings, and a console app published with
PublishAot (HTTP requester, cookies, HTTP cache, data: requester, navigator)
compiles without warnings and runs correctly.
GetAttachedFileName returned the Content-Disposition file name as sent, so a server
could pass "../../x" or "C:\x" to a WithStandardDownload callback that combines it
with a folder. Only the part after the last separator is kept, with ":" and invalid
file name characters replaced by "_"; "." and ".." become "_".
Ignore an Expires date with a day the month does not have
Reduce the attached file name to a plain file name
Make the library trim and Native AOT compatible
@FlorianRappl FlorianRappl added this to the v1.3.1 milestone Nov 8, 2026
michaelthyregod and others added 16 commits November 8, 2026 20:47
A page loads its resources in parallel, but the provider kept its cookies in a
List changed from all threads. Once a race left a null entry in it, every later
GetCookie and SetCookie threw, even without contention.

The cookies are now an array that is never changed in place: a change swaps in
a new array with Interlocked.CompareExchange, and readers keep the one they got.
A single thread writes the file at a time; a change made meanwhile is written in
its next round, so no thread waits. Cookies and FindCookies stay live views and
can now be enumerated while the cookies change.
RemoveCookies returned the lazy FindCookies query, which was evaluated after
the removal and was therefore always empty. RemoveAllCookies did not write the
cookie file, so a persistent provider got the cookies back on the next start.
Every store rewrote the origin.txt of its origin, so parallel loads from one
origin collided on it (51 of 64 parallel stores failed in a repro), and stores
of one key could collide on the swap. The IOException reached the page load.

origin.txt is only written when missing, as its content follows from the folder
name. A store that still collides with another one is dropped and its temporary
file deleted: the other entry is as good, and like a failed read, a failed store
only means a cache miss later.
Copying the whole array on every change made writing a cookie more expensive.
The cookies are now a ConcurrentDictionary keyed like FindCookie (canonical
domain, path, name), so adding, replacing and removing a cookie is a single
dictionary call instead of a search through the list. Reading keeps the order
of the former sorted list; the file is still written by one thread at a time.
Return the removed cookies and persist RemoveAllCookies
Readers use the current list without copying it; a change copies the list, applies the existing code to the copy and swaps it in. The file is still written by one thread at a time.
Make the cookie provider safe for parallel use
HttpCache now queues its handler writes per origin (WriteQueue), so handlers never see parallel writes; the changes to PersistenceHttpCacheHandler are undone.
…tores

Let parallel stores to the persistent HTTP cache succeed
@FlorianRappl
FlorianRappl merged commit 3e2fa89 into main Nov 9, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants