basecamp / basecamp/lexxy

`body_before_type_cast` returns ciphertext for encrypted ActionText

Open Beginner friendly
#972 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.2k
Forks
119
Avg merge
4d 8h
Merged PRs (30d)
15

Description

# `body_before_type_cast` returns ciphertext for encrypted ActionText

Hey — first off, thank you for Lexxy. We're using it in production and it's a genuine pleasure to work with. 🙏

## The issue

`render_custom_attachments_in` uses `body_before_type_cast` to read ActionText content. When the rich text field uses `encrypted: true` (i.e. `has_rich_text :content, encrypted: true`), that method bypasses AR encryption and returns the raw ciphertext instead of HTML.

The editor ends up displaying something like:

```
{"p":"c9RimfrrLIg...","h":{"iv":"yy1Qrgna...","at":"rgLYJb4r...","c":true}}
```

## Where

`lib/lexxy/rich_text_area_tag.rb` — the `render_custom_attachments_in` method:

```ruby
if html = value.body_before_type_cast.presence
```

## Suggested fix

`body.to_html` decrypts transparently and works for both encrypted and non-encrypted ActionText:

```ruby
if html = value.body&.to_html.presence
```

We're running a monkey-patch with this change and it's working well. Happy to open a PR if that'd be helpful.

Curious — do any of the Basecamp apps use AR encryption on Lexxy-backed fields? If so, wondering if you've hit this too or handle it differently.

Thanks again for all the work on this!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in lib/lexxy/rich_text_area_tag.rb at render_custom_attachments_in and inspect how body_before_type_cast is used. Reproduce the behavior with encrypted and non-encrypted ActionText fields, then verify that custom attachments render HTML in both cases rather than ciphertext.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
backend, content
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.