fix: comprehensive NDEF parsing - replace ParseNDEFData with ParseNDEFMessage for all tag types#5
Merged
wizzomafizzo merged 4 commits intomainfrom Aug 14, 2025
Merged
Conversation
…ds present At the moment it attempts to parse the first text only record which will fail (no NDEF data) if the tag contains other kinds of records e.g. a URI exclusively
- Fix MIFARE Classic, NTAG, and FeliCa tags to use ParseNDEFMessage - Update all related tests to use the correct function - This ensures URI, WiFi, vCard, and other non-text NDEF records work properly - ParseNDEFData only handled text records, causing 'no NDEF data' errors for other types Fixes comprehensive NDEF parsing for all tag types, not just MIFARE Classic.
- Function was fundamentally broken (text-only parsing) - All usages have been replaced with ParseNDEFMessage - Eliminates 67 lines of dead/broken code - Prevents future accidental usage of the broken function
- Remove extra blank line in ndef.go (gci formatting) - Break long line in ndef_construction_test.go (line length limit) All linters now pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR provides a comprehensive fix for NDEF parsing across all NFC tag types by replacing the broken
ParseNDEFDatafunction with the properParseNDEFMessageimplementation.Problem Description
The current codebase had a fundamental architectural issue where
ParseNDEFDataonly parsed text records, causing all other NDEF record types to fail with "no NDEF data" errors:This affected all tag types: MIFARE Classic, NTAG, and FeliCa.
Root Cause Analysis
ParseNDEFDatawas a legacy function with hardcoded text-only parsing// TODO: Properly parse full NDEF structureParseNDEFMessageis the modern implementation usinggo-ndeflibraryParseNDEFMessageproperly handles all NDEF record typesChanges Made
Code Updates
mifare.go:450- Fixed MIFARE Classic ReadNDEFntag.go:227- Fixed NTAG ReadNDEF (first method)ntag.go:395- Fixed NTAG readNDEFBlockByBlock methodfelica.go:362- Fixed FeliCa ReadNDEFparameter_validation_test.go- Updated test referencesndef_construction_test.go- Updated test function name and referencesCode Removal
ndef.go- Removed the brokenParseNDEFDatafunction (67 lines of dead code)Testing
Impact
This fix enables proper NDEF parsing for modern NFC applications that use:
Relationship to PR #2
This extends and supersedes the fix originally proposed in PR #2, providing a complete solution that affects all tag types rather than just MIFARE Classic, plus removes the broken legacy code entirely.