Skip to content

fix: stop storing HTML entities and decode legacy entity-encoded data#702

Open
anonymoususer72041 wants to merge 3 commits intoopencats:masterfrom
anonymoususer72041:fix/html-entity-storage
Open

fix: stop storing HTML entities and decode legacy entity-encoded data#702
anonymoususer72041 wants to merge 3 commits intoopencats:masterfrom
anonymoususer72041:fix/html-entity-storage

Conversation

@anonymoususer72041
Copy link
Contributor

@anonymoususer72041 anonymoususer72041 commented Jan 25, 2026

Summary

This PR prevents text fields from being stored as HTML entities by switching internal/admin write paths from getSanitisedInput() to trimmed raw input. It also normalizes escaping in a few templates where affected fields were echoed without the standard escaping helper.

To keep existing installations consistent, this PR adds an installer schema upgrade that detects entity-encoded values in common text columns (job orders, companies, contacts, candidates, activities, calendar events) and decodes them back to raw UTF-8. The migration decodes repeatedly until the value becomes stable (with a conservative safety cap) to handle multi-encoded legacy data.

Note: The public Careers Portal (modules/careers/CareersUI.php) is intentionally left functionally unchanged in this PR. Related input/output hardening is being handled in PR #697. Once #697 lands, we can reassess whether additional adjustments are needed here without overlapping changes.

Motivation

While working on the special-character issues addressed in #701, it became apparent that some code paths still transform user input before it reaches the database, resulting in HTML entities being persisted. This can lead to double-escaping and inconsistent rendering of special characters across modules and environments.

By standardizing on "store raw, escape on output" and providing a best-effort upgrade step to normalize legacy data, this PR reduces character corruption risks without tackling formatting concerns like line break rendering yet.

@RussH
Copy link
Member

RussH commented Mar 17, 2026

@anonymoususer72041 Thanks for the PR. It looks like this now has conflicts with the current master, so it’ll need to be updated before it can be merged.

Please could you rebase onto the latest master (or merge master into your branch), resolve the conflicts, and push the updated branch?

GitHub is currently showing conflicts in:

modules/candidates/CandidatesUI.php

modules/companies/CompaniesUI.php

modules/companies/Show.tpl

modules/contacts/ContactsUI.php

modules/install/Schema.php

test/data/test.sql

Once that’s done, I'll take a look. Thanks!

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