-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
🐛 fix Utils.unescape
for '%' characters
#28
Conversation
WalkthroughThe unescape method within the Utils class has been refactored to improve its error handling. The updated code performs bounds checking on escape sequences and employs try-catch blocks to manage potential hexadecimal parsing errors, thus preventing runtime issues. In addition, a more comprehensive test suite has been added to verify both escape and unescape functionalities across a range of character inputs, including edge cases and various formatting scenarios. Changes
Sequence Diagram(s)sequenceDiagram
participant C as Caller
participant U as Utils.unescape
participant P as Hex Parser
C->>U: Call unescape(inputString)
U->>U: Check for sufficient characters after '%'
alt Sufficient characters available
U->>P: Attempt to parse hex/unicode escape
alt Parsing succeeds
P-->>U: Parsed character
U-->>C: Return unescaped string
else Parsing fails (FormatException)
U->>U: Catch exception and treat '%' as literal
U-->>C: Return unescaped string with literal '%'
end
else Insufficient characters
U-->>C: Return unescaped string treating '%' as literal
end
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesCodacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #28 +/- ##
==========================================
+ Coverage 97.32% 97.38% +0.05%
==========================================
Files 14 14
Lines 674 689 +15
==========================================
+ Hits 656 671 +15
Misses 18 18 ☔ View full report in Codecov by Sentry. |
This pull request includes significant changes to the
Utils
class and its associated unit tests to improve the handling of escape sequences and ensure robustness in edge cases.Improvements to escape sequence handling:
lib/src/utils.dart
: Enhanced the escape sequence handling in theUtils
class by adding checks for valid escape sequences and handling invalid cases more gracefully. This includes treating '%' as a literal when it is the last character or followed by an invalid escape sequence.Enhancements to unit tests:
test/unit/utils_test.dart
: Added comprehensive test cases for theescape
method to cover various scenarios, such as alphanumeric characters, accented characters, non-ASCII characters, and different punctuation marks.test/unit/utils_test.dart
: Expanded theunescape
method tests to include cases with uppercase and lowercase hex digits, Unicode escapes, mixed literal text and escapes, and invalid escape sequences. [1] [2]