Repository navigation
Conversation
The calendar client still hard-codes raw.githubusercontent.com, so `calendar day` and `tis schedule` fail on networks where that host is unreachable even after the online layer became configurable. Extract the HTTPS base resolution shared with the online layer and add SUSTECH_CALENDAR_RAW_BASE, defaulting to the public calendar repository. Values must be plain HTTPS URLs without a query or fragment; invalid values fail with CALENDAR_RAW_BASE_INVALID. Also make the online default-base test hermetic when SUSTECH_ONLINE_RAW_BASE is set in the caller's environment, and document both variables in the README. Refs wormforce#29, wormforce#30.
A base URL such as https://user:token@mirror.example/repo would send the embedded secret to the mirror. Reject any URL with userinfo so SUSTECH_CALENDAR_RAW_BASE and SUSTECH_ONLINE_RAW_BASE cannot smuggle credentials into requests. Cover both resolvers with tests and update the README and online docs.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Collaborator
|
Thanks @FortuneCatOfSummer — exactly the calendar follow-up we wanted after #30. Shared |
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.
Summary
src/core/raw-base.tsSUSTECH_CALENDAR_RAW_BASEfor the academic calendar, defaulting tohttps://raw.githubusercontent.com/dumixthestpd/sustech-calendar/mainquery string or fragment, with
CALENDAR_RAW_BASE_INVALIDSUSTECH_ONLINE_RAW_BASEis set in the caller's environmentFollow-up to #30, refs #29.
Why
src/calendar/client.tsstill hard-coded the same raw GitHub base, socalendar dayandtis schedulekept failing on restricted networks evenafter the online layer became configurable.
Behaviour
SUSTECH_CALENDAR_RAW_BASE=https://ghfast.top/https://raw.githubusercontent.com/dumixthestpd/sustech-calendar/main:calendar reads go through the mirror.
CALENDAR_RAW_BASE_INVALIDinstead of silentlyreading another source.
Security
The shared resolver rejects URLs with embedded credentials for both
SUSTECH_CALENDAR_RAW_BASEandSUSTECH_ONLINE_RAW_BASE, so a mirror URLcannot carry a token into request headers or error output. The online layer
also keeps its exact URL allowlist and
redirect: "error"behaviour.Tests
npm run checknpm test— newsrc/test/calendar-raw-base.test.tscovers the default, amirror override, trailing-slash/whitespace trimming, invalid values including
userinfo, and that
loadYearrequests the configured base. 504 tests: 487pass, 12 skip; the 5 failures are the pre-existing Windows symlink tests
(
EPERMwithout Developer Mode).