aboutsummaryrefslogtreecommitdiff
path: root/core/encoding
Commit message (Collapse)AuthorAgeFilesLines
* encoding/json: marshal enumerated arrays to objects with key-value pairsjkenda2025-02-011-3/+13
|
* Fix stray space vs. tabJeroen van Rijn2025-01-121-4/+4
|
* Merge pull request #4634 from dozn/patch-1gingerBill2025-01-061-2/+2
|\ | | | | Use Struct Tags For Embedded (with `using`) Structs When Unmarshalling JSON
| * Remove unnecessary string() conversion.dozn2024-12-281-1/+1
| |
| * Use Struct Tags For Embedded (with `using`) Structs When Unmarshalling JSONdozn2024-12-281-1/+1
| | | | | | A fix for https://github.com/odin-lang/Odin/issues/4539
* | encoding/base32: Add `@(rodata)` attribute to default tablesZoltán Kéri2025-01-031-0/+2
| | | | | | | | | | | | | | Add `@(rodata)` attribute to `ENC_TABLE` and `DEC_TABLE` to mark them as read-only data. This places these tables in the read-only section of the executable, protecting them from modification during program execution.
* | encoding/base32: Fix RFC 4648 references and add RFC reference URLZoltán Kéri2024-12-312-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | Fix incorrect RFC 4648 section references: - Add RFC URL reference at package level - Update Error enum documentation to reference correct sections: - Invalid_Character: Section 3.3 (non-alphabet characters) - Invalid_Length: Section 6 (base32 block size requirements) - Malformed_Input: Section 3.2 (padding) - Fix test file section references to match correct sections This ensures all RFC references are accurate and adds a link to the source RFC for reference.
* | encoding/base32: Fix style issues for CIZoltán Kéri2024-12-311-5/+4
| |
* | encoding/base32: Convert files to UTF-8 with Unix line endingsZoltán Kéri2024-12-301-223/+224
| |
* | encoding/base32: Add proper cleanup for encoded strings in testsZoltán Kéri2024-12-301-1/+3
| | | | | | | | | | | | Add defer delete for encoded strings across all test procedures to ensure proper cleanup and prevent memory leaks. This completes the memory management improvements started in 591dd876.
* | encoding/base32: Add custom alphabet test caseZoltán Kéri2024-12-301-0/+75
| | | | | | | | | | | | | | | | Add test case to verify custom alphabet support. The test uses a decimal-uppercase alphabet (0-9, A-V) to test both encoding and decoding with custom tables, including validation. This ensures the encode and decode functions work correctly with custom encoding tables and validation functions as documented.
* | encoding/base32: Remove incorrect defer delete in encode()Zoltán Kéri2024-12-301-1/+0
| | | | | | | | | | | | | | | | Remove premature deallocation of the output buffer which was causing use-after-free behavior. The returned string needs to take ownership of this memory, but the defer delete was freeing it before the string could be used. This fixes issues with encoding that were introduced by overly aggressive memory cleanup in 93238db2.
* | encoding/base32: Add encode->decode roundtrip testZoltán Kéri2024-12-301-0/+23
| | | | | | | | | | | | | | Add test_base32_roundtrip() to verify the encode->decode roundtrip preserves data integrity. This test helps ensure our base32 implementation correctly handles the full encode->decode cycle without data loss or corruption.
* | encoding/base32: Move tests to base32_test.odinZoltán Kéri2024-12-292-126/+127
| | | | | | | | | | Move existing test procedures to a dedicated test file for better code organization and maintainability.
* | encoding/base32: Expand `DEC_TABLE` to full 256 bytesZoltán Kéri2024-12-261-13/+15
| | | | | | | | | | | | The decoding table was only 224 bytes which caused type mismatches when using custom alphabets, so expand with zeroes to cover full byte range while maintaining the same decoding logic.
* | encoding/base32: Use `ENC_TBL` parameter consistently in encode()Zoltán Kéri2024-12-261-9/+9
| | | | | | | | | | | | | | Fix encoding to properly use provided encoding table parameter instead of hardcoded `ENC_TABLE`. This makes encode properly support custom alphabets as documented.
* | encoding/base32: Add custom validation supportZoltán Kéri2024-12-251-5/+16
| | | | | | | | | | | | | | | | Add support for custom alphabet validation through an optional validation function parameter. The default validation follows RFC 4648 base32 alphabet rules (A-Z, 2-7). This properly supports the documented ability to use custom alphabets.
* | encoding/base32: Replace padding map with switch statementZoltán Kéri2024-12-241-9/+11
| | | | | | | | | | | | Replace package-level map with a simple switch statement for padding validation. This eliminates allocations we can't properly free while maintaining the same validation logic.
* | encoding/base32: Set optimization mode for decode()Zoltán Kéri2024-12-241-0/+1
| |
* | encoding/base32: Use consistent allocator and add proper cleanupZoltán Kéri2024-12-241-22/+43
| | | | | | | | | | | | | | | | | | | | | | | | Fix memory handling throughout base32 package: - Make padding map package-level constant (to avoid repeated allocs) - Use passed allocator in encode's make() call - Add defer delete for allocated memory in encode - Add proper cleanup in test cases - Fix memory cleanup of output buffers The changes ensure consistent allocator usage and cleanup in both implementation and tests.
* | encoding/base32: Fix decode implementation per RFC 4648Zoltán Kéri2024-12-241-58/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rework base32.decode() to properly handle all cases per RFC 4648: - Fix error detection order: - Check minimum length first (Invalid_Length) - Check character validity (Invalid_Character) - Check padding and structure (Malformed_Input) - Fix padding validation: - Add required padding length checks (2=6, 4=4, 5=3, 7=1 chars) - Ensure padding only appears at end - Fix handling of unpadded inputs - Fix buffer handling: - Proper output buffer size calculation - Add bounds checking for buffer access - Add proper buffer validation For example: - "M" correctly returns Invalid_Length (too short) - "mzxq====" correctly returns Invalid_Character (lowercase) - "MZXQ=" correctly returns Malformed_Input (wrong padding) - Unpadded input lengths must be multiples of 8 These changes make the decode function fully compliant with RFC 4648 requirements while providing proper error handling.
* | encoding/base32: Add RFC 4648 test suiteZoltán Kéri2024-12-241-0/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add test suite based on RFC 4648 test vectors and validation rules: - Add section 10 test vectors for valid encoding/decoding - Add test cases for invalid character handling (section 3.2) - Add test cases for padding validation (section 4) - Add test cases for length requirements (section 6) The test vectors verify that: - Empty string encodes/decodes correctly - Standard cases like "foo" -> "MZXW6===" work - Invalid characters are rejected - Missing or malformed padding is detected - Invalid lengths are caught
* | encoding/base32: Fix buffer allocation and bounds checkingZoltán Kéri2024-12-241-6/+24
| | | | | | | | | | | | | | | | | | | | | | Fix buffer allocation size calculation and add proper bounds checking to ensure output buffer has sufficient space. This fixes crashes that could occur with inputs like "AA" and other edge cases where the output buffer was too small. Remove #no_bounds_check as proper bounds checking is necessary for safe error handling. The small performance trade-off is worth the improved robustness.
* | encoding/base32: Replace assertions with error returnsZoltán Kéri2024-12-241-9/+31
|/ | | | | | | Replace assertions with proper error handling in base32.decode() to allow programs to handle invalid input gracefully rather than crashing. The function now returns ([]byte, Error) instead of just []byte.
* fix #4536 - stack buffer overflow for size_of 0 types in struct unmarshalLaytan Laats2024-12-061-1/+1
|
* Merge pull request #4562 from dozn/patch-1gingerBill2024-12-061-3/+3
|\ | | | | Move Struct Field Zipping Outside of Loop
| * Move Struct Field Zipping Outside of JSON Token Loopdozn2024-12-051-3/+3
| |
* | Fix #4537gingerBill2024-12-051-0/+1
|/
* Fix #4549gingerBill2024-12-021-1/+1
|
* fix unmarshal unhandled error (#4515)o:tone2024-11-251-1/+1
| | | * fix unmarshal unhandled error
* Fix a bug in hxa decoder found by the new checkjakubtomsu2024-11-171-1/+1
|
* Check for more errors in json.unmarshalgingerBill2024-11-141-15/+34
|
* Remove relative types from json marshallergingerBill2024-11-141-6/+0
|
* fix cbor.to_json always returning array of tuples for objectsAlexis Caraballo2024-10-291-1/+1
| | | | to_json uses a small proc to check if all keys of an object are strings. It was always returning false for any input.
* encoding/cbor: fix skipping of ignored/missing fields in struct unmarshalLaytan Laats2024-10-261-0/+2
|
* encoding/cbor: handle binary having more fields than the struct by discardingLaytan Laats2024-10-251-1/+13
|
* cbor: fix capacity and ptr calculation for dynarray unmarshalTom Solberg2024-10-201-4/+5
|
* encoding/json: fix leak when string is unmarshalled into non-string fieldLaytan Laats2024-10-191-5/+10
| | | | Fixes #4391
* [encoding/ini]: Add missing line terminator at the end of the sectionflysand72024-09-241-0/+1
|
* core/encoding/cbor: allow unmarshalling non-string map keysLaytan Laats2024-09-111-27/+11
|
* Merge pull request #4191 from laytan/improve-package-doc-commentsgingerBill2024-09-0412-239/+257
|\ | | | | core: improve package doc comments for the documentation generator
| * core: improve package doc comments for the documentation generatorLaytan Laats2024-09-0312-239/+257
| |
* | unmarshal bitset ints like cbor doesjakubtomsu2024-09-041-1/+24
|/
* fix some doc commentsLaytan Laats2024-09-021-1/+1
|
* encoding/csv: fix examplesLaytan Laats2024-08-301-4/+6
|
* Fix error for uuid to require 36 bytes instead 32 (4 bytes for dashes)Ed Yu2024-08-261-15/+20
|
* encoding/cbor: various fixesLaytan Laats2024-08-093-10/+20
| | | | | | | - "null" is the proper way to represent the nil value in the diagnostic format - hex encoding in diagnostic format was wrong - struct keys weren't sorted the right deterministic way
* Update example to use `err != nil` insteadgingerBill2024-08-041-3/+3
|
* Tidy up codeRonald2024-07-211-2/+1
|
* Ensure that values in ini map are unquotedRonald2024-07-211-0/+2
|