Skip to content

Android: attaching a file whose name contains [ or ] fails with "Illegal character in path" #28956

Closed

Description

@arandomhooman

What happened

On the Android app, attaching a PDF whose name contains square brackets (e.g. … Oxford [Oxfordshire] …pdf) fails with a "Could not attach file" alert. Other files attach fine.

Diagnosis

persistComposerAttachmentFile (apps/mobile/src/lib/composerImages.ts) builds the destination with new File(directory, ${uuidv4()}-${safeName}). safeName only replaces /, \ and control characters.

expo-file-system 58.0.9 builds the URI with encodeURLChars and the WHATWG URL pathname setter, which escape spaces, %, ?, # and non-ASCII characters but leave [, ] and | raw. On Android, JavaFile calls File(URI.create(uri.toString())) (unifiedfile/JavaFile.kt). java.net.URI rejects those characters, so copy() throws; index 218 in the error is the first [. The chunked-copy path for content: sources calls destination.create() on the same URI and should fail the same way.

downloadFileName (apps/mobile/src/lib/attachmentDownload.ts) has the same gap, so downloads probably fail too (not reproduced).

Suggested fix: the on-disk name is internal and the original is kept in name, so map everything outside [A-Za-z0-9._ -] to - and keep the extension. Checked against main @ fa31b66.

Steps to reproduce

  1. On Android, open a thread and tap + to attach a file.
  2. Pick a file named e.g. Report [draft].pdf.

Version

2.2.0

Environment

Android app, connected to a Windows 11 desktop host

Evidence

Call to function 'FileSystemFile.copy' has been rejected.
→ Caused by: java.lang.IllegalArgumentException: Illegal character in path at index 218:
file:///data/user/0/com.t3tools.t3code/files/t3-composer-attachments/d16e49e7-…-<title>%20--%20Oxford%20[Oxfordshire]%20;%20New%20York,…pdf

Related issues

None in pingdotgg/t3code (supersedes #28951, closed to refile here). Upstream: expo/expo#35619 and expo/expo#48496 are the same kind of bug.

Fix applied or workaround

None applied. Workaround: rename the file to remove brackets.

Filed by

claude (opus-5.5) via T3 Code

Activity

  1. arandomhooman commented on Nov 1, 2026

    @arandomhooman
    Author
    Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    via-triageFiled through npx t3 triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions