-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Summary
FilePreview components should sanitize user-controlled input to prevent potential security issues and improve robustness.
Affected Components
FilePreview.tsx- Displays metadata without validationTextViewer.tsx- Renders content directlyImageViewer.tsx- Uses metadata for attributes
Details
Current Behavior
Components directly render user-provided metadata (filenames, content) without sanitization:
// Example areas for improvement
<span>{metadata.name}</span>
<object aria-label={filename} title={filename} />
<img alt={filename} />Proposed Enhancement
Implement input sanitization following security best practices:
- Add sanitization dependency (e.g., DOMPurify)
- Create validation utilities
export const sanitizeDisplayText = (text: string): string => {
// Sanitize text for safe display
return sanitizedText;
};- Apply sanitization consistently
// Safe rendering approach
<span>{sanitizeDisplayText(metadata.name)}</span>
<object aria-label={sanitizeDisplayText(filename)} />
<img alt={sanitizeDisplayText(filename)} />Metadata
Metadata
Assignees
Labels
No labels