-
Notifications
You must be signed in to change notification settings - Fork 0
π‘οΈ Sentinel: [security improvement] localStorage νκ²½ κ²μ¦ μΆκ° #194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -301,8 +301,10 @@ function preferredLanguage() { | |
| if (allowed.includes(query)) return query; | ||
|
|
||
| try { | ||
| const saved = localStorage.getItem("cwl-language"); | ||
| if (allowed.includes(saved)) return saved; | ||
| if (typeof window !== 'undefined' && window.localStorage) { | ||
| const saved = localStorage.getItem("cwl-language"); | ||
| if (allowed.includes(saved)) return saved; | ||
| } | ||
|
Comment on lines
+304
to
+307
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π©Ί Stability & Availability | π Major | ποΈ Heavy lift π Supported by static analysisπ Script executed: printf '%s\n' '--- repository guidance ---'
find /tmp/coderabbit-repo-knowledge/contextualwisdomlab-contextualwisdomlab-github-i-e404bc33 -type f -path '*/contextualwisdomlab*/*.md' -o -path '*/learnings/*.md' 2>/dev/null | sort | while read -r f; do
printf '\n--- %s ---\n' "$f"
head -80 "$f"
done
printf '%s\n' '--- i18n.js target and surrounding definitions ---'
sed -n '285,325p;370,405p' i18n.js
printf '%s\n' '--- preferredLanguage callers ---'
rg -n -C 3 'preferredLanguage|setLanguage\(' --glob '!*node_modules*' .Repository: ContextualWisdomLab/ContextualWisdomLab.github.io Length of output: 14493 π Script executed: printf '%s\n' '--- exact change ---'
git diff -- i18n.js
printf '%s\n' '--- top-level execution context ---'
sed -n '1,35p;298,318p;395,408p' i18n.jsRepository: ContextualWisdomLab/ContextualWisdomLab.github.io Length of output: 2784 SSR νκ²½μ μ μ κ°μ²΄ μ κ·Όμ 보νΈνμμμ€.
π€ Prompt for AI Agents |
||
| } catch (error) { | ||
| // Fail securely: ignore localStorage errors in strict privacy modes | ||
| } | ||
|
|
@@ -385,7 +387,9 @@ function setLanguage(lang) { | |
| }); | ||
|
|
||
| try { | ||
| localStorage.setItem("cwl-language", lang); | ||
| if (typeof window !== 'undefined' && window.localStorage) { | ||
| localStorage.setItem("cwl-language", lang); | ||
| } | ||
| } catch (error) { | ||
| // Fail securely: ignore localStorage errors | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π Info: SSR guard undercut by earlier window access
The new
typeof window !== 'undefined'guards at i18n.js and i18n.js aim for SSR safety, butpreferredLanguage()already readswindow.location.searchunconditionally at i18n.js andsetLanguage()usesdocumentthroughout. A true no-window environment throws before reaching either guard, so the SSR goal is not met by these guards alone.Was this helpful? React with π or π to provide feedback.