Skip to content
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

Enhance Sanitizer Component and README Updates #4

Merged
merged 7 commits into from
Oct 23, 2024
Merged

Conversation

walmir-silva
Copy link
Contributor

This pull request contains several improvements and updates to the KaririCode Sanitizer component. The main changes include:

Sanitizer Enhancements:

  • Refactoring:
    • Split HtmlPurifierSanitizer into modular components to improve maintainability and reusability.
    • Extract classes within the FilenameSanitizer to adhere to the Single Responsibility Principle.
  • Test Improvements:
    • Updated HtmlPurifierSanitizer tests to align with the new modular structure.
    • Enhanced overall sanitizers' implementation and increased test coverage.

Application Improvements:

  • Added support for search and plain text fields to the application using the Sanitizer component.

Documentation:

  • Updated the README files in both English and Portuguese:
    • Improved descriptions for better clarity.
    • Expanded usage examples to showcase advanced usage scenarios.
    • Detailed explanations on available configuration options and integration with other KaririCode components.

- Remove debugging var_dump statement that was causing risky test warnings
- Clean up TrimSanitizer implementation to follow best practices
- Improve code documentation with proper English comments
…erage

BREAKING CHANGES:
- PhoneSanitizer now removes non-numeric by default, formatting is optional
- AlphanumericSanitizer has improved special character handling
- All sanitizers now have consistent default behaviors

Features:
- Add comprehensive test suites for all sanitizers
- Add new configuration options for better flexibility
- Implement trait-based code sharing between sanitizers

Improvements:
- Better handling of edge cases in all sanitizers
- More consistent and predictable behavior
- Enhanced code organization and documentation
- Clear separation between sanitization and formatting
- Better error handling and validation

Sanitizers affected:
- HtmlSpecialCharsSanitizer
- NormalizeLineBreaksSanitizer
- StripTagsSanitizer
- TrimSanitizer
- EmailSanitizer
- NumericSanitizer
- PhoneSanitizer
- UrlSanitizer
- AlphanumericSanitizer

Tests:
- Add comprehensive test cases
- Improve test coverage to 100%
- Add edge case testing
- Better test organization and documentation
BREAKING CHANGE: HtmlPurifierSanitizer internal structure has been reorganized

- Create new namespace KaririCode\Sanitizer\Processor\Domain\HtmlPurifier
- Split functionality into specialized classes:
  - Config/Configuration: Manage allowed tags and attributes
  - Dom/DomHandler: Handle DOM operations
  - NodeSanitizer/NodeSanitizer: Process DOM nodes
  - Cleaner/InputCleaner: Pre-process input
  - Cleaner/OutputCleaner: Post-process output
  - AttributeCleaner/AttributeCleaner: Handle attribute sanitization
… behavior

Following the refactoring of HtmlPurifierSanitizer, the tests have been updated to:

- Add explicit allowedTags configuration in each test case
- Verify content preservation when tags are removed
- Test hierarchical structure maintenance
- Ensure attribute handling works correctly for allowed/disallowed tags
- Create namespace KaririCode\Sanitizer\Processor\Security\Filename
- Split FilenameSanitizer into specific classes:
  * ExtensionHandler: handling of extensions and validations
  * FilenameParser: parsing and splitting of filenames
  * BasenameSanitizer: sanitization of the base name
  * Configuration: configuration management
  * FilenameSanitizer: orchestration of the process
- Add `searchQuery` and `plainTextContent` fields to the `JobApplication` class
- Implement getter/setter methods for the new fields
- Update `displayResults` function to show the new fields
- Add data examples to test the new sanitizers
- Revised and enhanced descriptions in both English and Portuguese README.
- Expanded usage examples for better clarity.
- Added more details about sanitizer configuration options.
- Updated integration and registry explanation sections.
@walmir-silva walmir-silva merged commit f675fb4 into main Oct 23, 2024
1 check passed
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.

1 participant