Repository navigation
Release 1.3.1 - #63
Merged
Merged
Conversation
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
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.
This reverts commit 9ed425b.
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.
This reverts commit c2d8f5a.
Make the cookie provider safe for parallel use
# Conflicts: # CHANGELOG.md
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Types of Changes
Prerequisites
Please make sure you can check the following two boxes:
Contribution Type
What types of changes does your code introduce? Put an
xin all the boxes that apply: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.