Skip to content

fix(network): modernize WebDAV date parsing - #2138

Draft
joshtrichards wants to merge 5 commits into
masterfrom
jtr/fix-webdav-date-parsing
Draft

fix(network): modernize WebDAV date parsing#2138
joshtrichards wants to merge 5 commits into
masterfrom
jtr/fix-webdav-date-parsing

Conversation

@joshtrichards

@joshtrichards joshtrichards commented Sep 10, 2026

Copy link
Copy Markdown
Member

This started with looking to pare down the legacy compatibility list (inherited from several generations of ancient third-party code) and making the patterns and parsing more robust.

Replace legacy SimpleDateFormat parsing with strict, thread-safe DateTimeFormatter instances for WebDAV and Share API date formats.

The change also separates HTTP/WebDAV date parsing from Share API expiration parsing.

Retains support for legacy HTTP date formats, though I nearly left it out, as I highly doubt that part is really needed.

Changes:

  • Replace the shared, synchronized SimpleDateFormat array.
  • Parse current HTTP dates using strict IMF-fixdate handling.
  • Preserve support for RFC 850 and ANSI C asctime() HTTP dates.
  • Apply RFC-defined two-digit-year handling for RFC 850 dates.
  • Add a dedicated parser for Share API expiration values.
  • Update ShareXMLParser to use the Share API-specific parser.
  • Add unit tests for WebDAV and Share API date parsing.

The previous implementation tried a shared list of unrelated formats in sequence, synchronized access to mutable SimpleDateFormat instances, and used exceptions for normal format probing. This was especially inefficient for Share API expiration values, whose matching format appeared near the end of the list.

Dedicated immutable formatters now select the appropriate HTTP/WebDAV or Share API format directly, avoiding unnecessary parse attempts, exception overhead, and lock contention.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Replace the legacy multi-format SimpleDateFormat parser with thread-local, non-lenient parsers for current Nextcloud HTTP and Share API date formats. Require complete input consumption and interpret HTTP dates in UTC while preserving the existing
millisecond-based date model.

Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Replace legacy SimpleDateFormat parsing with strict, thread-safe DateTimeFormatter instances for current WebDAV and Share API date
formats.

Signed-off-by: Josh <josh.t.richards@gmail.com>
Add RFC 850 and ANSI C asctime() parsing to preserve compatibility with obsolete but valid HTTP-date representations, including the RFC-defined handling of two-digit years.

Signed-off-by: Josh <josh.t.richards@gmail.com>
Add unit tests for IMF-fixdate, RFC 850, and ANSI C asctime() parsing, including strict validation, null and empty inputs, and RFC 850 compatibility.

Also verify dedicated Share API expiration parsing, 24-hour timestamps, invalid dates, and rejection of HTTP-date values.

Assisted-by: Copilot:gpt-5.6-luna

Signed-off-by: Josh <josh.t.richards@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

SpotBugs

CategoryBaseNew
Bad practice3131
Correctness2828
Dodgy code1313
Internationalization66
Malicious code vulnerability2626
Multithreaded correctness77
Performance33
Security33
Total117117

@nextcloud-android-bot

Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants