fix: sanitize custom IM type label before using as IMPP URI scheme#543
Open
faraz152 wants to merge 1 commit intoFossifyOrg:mainfrom
Open
fix: sanitize custom IM type label before using as IMPP URI scheme#543faraz152 wants to merge 1 commit intoFossifyOrg:mainfrom
faraz152 wants to merge 1 commit intoFossifyOrg:mainfrom
Conversation
Custom IM type labels are used as the URI scheme when building IMPP
properties (e.g. `a b:username`). URI schemes only allow the character
set [a-zA-Z][a-zA-Z0-9+-.]*; a label containing spaces or other
special characters caused ez-vcard's Impp constructor to throw an
IllegalArgumentException, which silently aborted the export and left
a 0-byte file on disk.
Fix: replace any character outside the valid URI-scheme set with a
hyphen before constructing the Impp object. Also guard against labels
that start with a non-letter (prefix "x-") or are empty ("x-custom").
Fixes FossifyOrg#499
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.
What
Fixes #499
A contact with a custom IM type containing a space (e.g.
"a b") caused sharing/export to fail silently — a 0-byte file was written and an error toast appeared.Root cause
VcfExporterpassesit.labeldirectly as the protocol argument to ez-vcard'sImpp(String protocol, String handle)constructor. That constructor builds ajava.net.URIusing the protocol string as the URI scheme. URI schemes only allow[a-zA-Z][a-zA-Z0-9+-.]*, so a label containing a space throwsIllegalArgumentException, which propagates up and aborts the export.Fix
Before constructing the
Imppproperty, replace any character outside the valid URI-scheme set with a hyphen. Two additional guards:"x-"(scheme must begin withALPHA)"x-custom"Testing
Manually verified:
"a b"with a username.IMPP:a-b:username.Compiled and linted against
fossDebugvariant — no errors or new warnings.Note on round-trip fidelity
Labels with spaces will be stored as hyphen-separated strings in the exported VCF (e.g.
"a b"→"a-b"). Preserving the original label through the URI scheme is not possible without a larger structural change (URI schemes forbid percent-encoding). This is a known limitation documented in the code comment.