fix: normalize backslashes in image URLs for Windows paths#101
Conversation
Windows-style paths (adminimgs\project_1.png) caused 404s because backslashes aren't valid in URLs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR normalizes Windows-style backslashes to forward slashes in image paths and URLs across the server API handler, remark markdown plugin, and path safety utility. Test coverage verifies backslash normalization, correct URI encoding, and path traversal safety throughout the pipeline. ChangesImage Path Backslash Normalization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/chronicle/src/server/utils/safe-path.test.ts`:
- Line 3: Replace the relative import of safePath (import { safePath } from
'./safe-path') with the project path alias import using @ so it follows TS/Vite
path mapping; for example change it to import { safePath } from
'`@/server/utils/safe-path`' (i.e., use '`@/`...' instead of './...') so the test
uses the configured `@/`* alias.
In `@packages/chronicle/src/server/utils/safe-path.ts`:
- Line 8: The decodeURIComponent call can throw on malformed percent-escapes, so
guard it: wrap the decodeURIComponent(urlPath.split('?')[0]) call used to
compute the decoded variable in a try/catch and on any error return null (or
otherwise signal an unsafe path) instead of letting the exception bubble;
preserve the subsequent .replace(/\\/g, '/') normalization only when decoding
succeeds so that the decoded variable and any surrounding function (the code
that computes decoded from urlPath) never throw on bad input.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 53c0ca1c-2d6c-4fab-aeaa-70dfaec1898f
📒 Files selected for processing (5)
packages/chronicle/src/lib/image-utils.test.tspackages/chronicle/src/lib/remark-resolve-images.tspackages/chronicle/src/server/api/image.tspackages/chronicle/src/server/utils/safe-path.test.tspackages/chronicle/src/server/utils/safe-path.ts
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
adminimgs\project_1.png)Changes
remark-resolve-images.ts— normalize\to/before resolving URLsimage.ts— normalize incomingurlparamsafe-path.ts— normalize decoded path before resolutionTest plan
Generated with Claude Code