Skip to content

Fix multiple code quality and security issues#11

Open
oyvindbso wants to merge 3 commits into
mainfrom
claude/code-review-fixes-01VhoFBw4EGPjaxHKgwXuxCG
Open

Fix multiple code quality and security issues#11
oyvindbso wants to merge 3 commits into
mainfrom
claude/code-review-fixes-01VhoFBw4EGPjaxHKgwXuxCG

Conversation

@oyvindbso
Copy link
Copy Markdown
Owner

This commit addresses several critical and high-severity issues identified during code review:

Security Fixes:

  • Disable cleartext HTTP traffic globally in network_security_config.xml
  • Remove API key logging (even partial) from ZoteroApiClient
  • Add null safety checks for API response fields to prevent NPEs

Resource Management:

  • Fix resource leak in writeResponseBodyToDisk() using try-with-resources
  • Properly close streams even if exceptions occur during file operations

Fragment Lifecycle:

  • Fix race conditions in CollectionFragment where getActivity() could become null between check and use
  • Store activity reference in local variable before checking and using it
  • Prevents crashes when fragments are detached during async operations

Build Configuration:

  • Enable lint checks (abortOnError and checkReleaseBuilds)
  • Remove duplicate testOptions blocks
  • Allow lint to catch issues before they reach production

This commit addresses several critical and high-severity issues identified during code review:

Security Fixes:
- Disable cleartext HTTP traffic globally in network_security_config.xml
- Remove API key logging (even partial) from ZoteroApiClient
- Add null safety checks for API response fields to prevent NPEs

Resource Management:
- Fix resource leak in writeResponseBodyToDisk() using try-with-resources
- Properly close streams even if exceptions occur during file operations

Fragment Lifecycle:
- Fix race conditions in CollectionFragment where getActivity() could become null between check and use
- Store activity reference in local variable before checking and using it
- Prevents crashes when fragments are detached during async operations

Build Configuration:
- Enable lint checks (abortOnError and checkReleaseBuilds)
- Remove duplicate testOptions blocks
- Allow lint to catch issues before they reach production
This commit adds a copy button to each book cover that copies either a web library link or internal Zotero link to the clipboard, based on user preference.

Features:
- Added small copy button (icon) in the top-right corner of each book cover
- New setting in Settings to choose between web library links and internal Zotero links
- Web link format: https://www.zotero.org/{username}/items/{itemId}
- Internal link format: zotero://select/library/items/{itemId}
- Toast notification confirms which link type was copied

Implementation:
- Added LINK_TYPE_WEB and LINK_TYPE_INTERNAL constants to UserPreferences
- Added getLinkType() and setLinkType() methods to UserPreferences
- Added link type radio group to Settings layout
- Created ic_copy.xml vector drawable (white copy icon)
- Modified grid_item_cover.xml to add ImageButton overlaying the cover image
- Updated CoverGridAdapter to handle copy button clicks and clipboard operations
- Updated SettingsActivity to load/save link type preference

User Experience:
- Small, unobtrusive button in corner of each cover
- Copies link instantly with visual feedback via toast
- User can configure link type once in settings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants