-
-
Notifications
You must be signed in to change notification settings - Fork 1
Professional iran system v1 1 0 10619367560126165419 #30
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?
Professional iran system v1 1 0 10619367560126165419 #30
Conversation
# Conflicts: # iran_encoding/__init__.py
- Ported legacy C logic to pure Python for zero-dependency reliability. - Implemented requested language detection and number handling rules. - Improved C extension and wrapper for performance optimization. - Professionalized documentation in English and Persian. - Updated and expanded test suite (all 37 tests passing). - Prepared for PyPI distribution as v1.1.0. Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
- Deleted redundant and failing `.github/workflows/python-package-conda.yml`. - Updated `.github/workflows/ci.yml` and `qodana-ci.yml` to run on all branches for better validation. - Updated `MANIFEST.in` to include C and H source files for proper source distribution. Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
…0-10619367560126165419 Professional overhaul of Iran System encoding library
- Fixed `qodana.yml` by merging duplicate `properties` keys. - Fixed `tests/test_suite.py` to correctly add the tests directory to `sys.path`, resolving `ModuleNotFoundError` during test collection in CI. - Verified fix by running `pytest` locally. Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
…0-10619367560126165419 fix: resolve CI failures in qodana and test suite
- Updated author metadata and support email in `setup.py`. - Overhauled README and Wiki documentation in both English and Persian. - Refactored Qodana configuration to `.qodana/qodana.yml`. - Cleaned up redundant files (`requirements.txt`, `test_encoding.py`). - Optimized CI workflows for the new project structure. Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
- Removed `.idea/` directory. - Refined `.gitignore` to include more specific exclusions for C compiled artifacts, IDE settings, and Qodana caches. Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
- Updated `qodana-ci.yml` to use `--yaml-name` instead of `-c` and upgraded action version to `v2024.3`. - Ensured all documentation and metadata are finalized. Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
- Fixed `qodana.yml` by quoting boolean values in `properties` to satisfy the `map[string]string` constraint. - Refined `exclude` section to use a standard format. - Updated `qodana-ci.yml` to symlink the config to the root for better compatibility with the Qodana action. - Verified all tests pass. Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
- Updated `publish-to-pypi.yml` to trigger automatically on push to `main`. - Added twine check step for package distribution validation. - Upgraded checkout and setup-python actions to latest versions. - Finalized professional configuration for release. Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
- Refactored `qodana.yaml` to use the correct `linter` key and hidden directory. - Updated `qodana-ci.yml` to point to the new configuration location. - Verified all tests pass. - Cleaned up .idea and refined .gitignore. - Finalized professional documentation and wiki. Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
- Updated `qodana.yaml` to use the correct `linter` key and Community image. - Quoted boolean values in `properties` to satisfy the map[string]string constraint. - Updated `qodana-ci.yml` to copy the configuration file to the root during analysis, ensuring the scan finds it. - Verified project integrity with all 76 tests passing. Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
- Removed redundant `bootstrap` command from `qodana.yaml`. - Set linter to `jetbrains/qodana-python-community:latest` for compatibility with the free version. - Simplified configuration properties. - Verified all tests pass. Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
- Removed `tests/corpus.json` as requested. - Verified that the visual encoding logic (parentheses and alphanumeric sequences) correctly matches legacy expectations. - Confirmed all 76 tests pass. Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
- Updated `encode` to produce visual RTL byte sequences as requested (e.g., "سلام" results in `f4 91 f3 a8`). - Updated `decode` to correctly handle visual RTL sequences and return logical Unicode. - Improved `ReverseAlphaNumeric` to accurately handle bi-directional chunks (English, numbers, symbols). - Ensured parity between Python and C implementations. - Updated all tests to reflect the visual ordering requirement. Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
Summary of ChangesHello @tahatehran, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request represents a significant architectural overhaul and professionalization of the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This is a massive and impressive refactoring that significantly improves the library. The removal of external dependencies, introduction of a pure Python core ported from C, addition of an optional C extension, and the vastly improved API, tests, and documentation are all excellent changes. However, I've identified a critical security vulnerability and a high-severity data loss bug in the C implementation that must be addressed. I've also noted a minor issue with an orphaned CLI argument and an opportunity to strengthen one of the new test cases.
I am having trouble creating individual review comments. Click here to see my feedback.
iran_encoding/iran_system.c (299-308)
There is a critical buffer overflow vulnerability here. The finalReverse buffer has a fixed size of 2048 bytes, but the loop iterates len times without checking if len is greater than or equal to 2048. This can lead to a crash or arbitrary code execution if a long string is passed. To fix this, you should use dynamic memory allocation (malloc/free) or pass the buffer and its size as parameters to ensure memory safety.
iran_encoding/iran_system.c (161-164)
These fixed-size buffers of 2048 bytes introduce a risk of data loss. The check on line 164 (if (len >= 2048) len = 2047;) prevents a buffer overflow but does so by silently truncating user data. For a library function, this can lead to subtle and hard-to-debug issues. It would be better to either handle arbitrarily long strings (e.g., using dynamic memory allocation) or return an error if the input string is too long, as silent data corruption is dangerous.
iran_encoding/cli.py (44-45)
While the usage of the --config argument is correctly removed here, its definition in the ArgumentParser setup (line 18 of the file) is now orphaned. To complete the removal of this deprecated feature, the argument definition should also be deleted from the CLI parser.
tests/test_iran_system_v1.py (40-61)
This test's assertion on line 61 is too weak to be meaningful; it only checks the type of the output. To properly test the visual ordering, you should assert that the output matches the exact expected byte sequence.
text = "سلام"
encoded = encode(text, visual_ordering=True)
# The expected visual order for "سلام" is 'م' 'ا' 'ل' 'س'
expected_bytes = bytes([0xF4, 0x91, 0xF3, 0xA8])
self.assertEqual(encoded, expected_bytes)
decoded = decode(encoded)
self.assertEqual(decoded, text)
…on/C parity - Implemented refined in-place Persian chunk reversal to better handle mixed English/Persian text. - Ensured English and numbers remain in logical LTR order for visual terminal compatibility. - Ported the full C logic to a pure Python core while maintaining a C performance fallback. - Updated documentation (README and Wiki) in both English and Persian. - Expanded test suite to cover mixed-text scenarios and verified 100% parity. - Bumped version to 1.2.0. Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
- Implemented Global RTL reversal with local chunk correction for LTR elements (English/Numbers). - Fixed digit mapping collisions between Persian letters and digits in the script tables. - Updated both Python and C engines to match the refined visual ordering logic. - Improved `decode` to handle pure ASCII strings logically (without reversal). - Verified with 45 tests covering mixed-text scenarios and Python/C parity. - Synchronized documentation to reflect the advanced visual ordering behavior. Co-authored-by: tahatehran <79411820+tahatehran@users.noreply.github.com>
No description provided.