Skip to content

Conversation

@vanmarkic
Copy link

Summary

  • Fixes issue where special characters in file content caused PATCH operations to fail
  • Adds proper header encoding for HTTP requests
  • Includes comprehensive test coverage

Changes

  • Implemented header encoding in PATCH operations to handle special characters
  • Added 209 lines of tests for various special character scenarios
  • Ensures proper handling of emojis, Unicode, and special symbols in file content

Related Issue

Fixes bug #30

🤖 Generated with Claude Code

…ters (jacksteamdev#30)

The patch_vault_file and patch_active_file functions were failing with HTTP 400 errors when the Target header contained:
- Multi-line text (newlines)
- Special characters (accented letters like é, à, etc.)
- Special Obsidian syntax (like [[wikilinks]])

This occurred because HTTP headers must be ASCII and cannot contain newlines or certain special characters. The fix applies URL encoding to the Target and Target-Delimiter header values using encodeURIComponent(), which:

- Converts newlines and special characters to safe percent-encoded format
- Maintains compatibility with standard HTTP header parsing
- Allows the Local REST API plugin to properly decode and process the values

This resolves the "Header 'Target' has invalid value" errors and allows patch operations to work correctly with complex target strings.

Fixes jacksteamdev#30
)

- Test encoding of special characters (#, &, ?, =, etc.)
- Test encoding of newline and carriage return characters
- Test encoding of multi-byte Unicode and emoji characters
- Test encoding of path separators (/ and \)
- Test encoding of whitespace (spaces, tabs)
- Test header construction with encoded target and delimiter
- Verify preservation of alphanumeric characters
- Verify trimTargetWhitespace boolean to string conversion
@netlify
Copy link

netlify bot commented Nov 15, 2025

Deploy Preview for superb-starlight-b5acb5 canceled.

Name Link
🔨 Latest commit 80431cb
🔍 Latest deploy log https://app.netlify.com/projects/superb-starlight-b5acb5/deploys/6918c173f110630008bb3342

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants