Skip to content

Fix bug that caused & to display and improve one-line rich-text fields#4267

Merged
mauromsl merged 12 commits into
release_1_5_xfrom
4258-bleach-and-html-entities
Jun 19, 2024
Merged

Fix bug that caused & to display and improve one-line rich-text fields#4267
mauromsl merged 12 commits into
release_1_5_xfrom
4258-bleach-and-html-entities

Conversation

@joemull

@joemull joemull commented Jun 10, 2024

Copy link
Copy Markdown
Member

Closes #4258.

This fixes a bug with ampersands reported in the issue above.

It also improves usability and handling of a number of related things:

  • Adds a Janeway custom bleach form field (previously we just had a custom bleach model field)
  • Changes the bleaching of setting to depend on setting type, meaning that charfields, text fields, numbers etc. are left alone--not even escaping of ampersands is applied
  • Adds a new setting type for one-line HTML fields, called "mini HTML"
  • Users can now edit one-line rich-text fields like article title with a small TinyMCE widget
  • Documents the four main text-related field types in Janeway fields and settings
  • Standardizes the setting types for settings that should use text, char, or mini-html to the appropriate type

@joemull joemull changed the base branch from master to release_1_5_x June 10, 2024 14:06
joemull added 7 commits June 10, 2024 17:23
By default, TinyMCE performs escaping on some characters
entered via the rich-text editing interface
(not the code view).

We want minimal escaping, so entity_encoding = 'raw'.

The TinyMCE docs on raw entity encoding:

All characters will be stored in non-entity form except
these XML default entities: &, <, >, ', and ".
@joemull joemull force-pushed the 4258-bleach-and-html-entities branch from 7b8aff3 to aa263db Compare June 11, 2024 12:15
@joemull joemull changed the title Handle Unicode and limited phrasing markup in bleached character fields Fix bug that caused &amp; to display and improve one-line rich-text fields Jun 11, 2024
@joemull joemull marked this pull request as ready for review June 11, 2024 12:20
@joemull joemull requested a review from mauromsl June 11, 2024 12:20
@joemull joemull changed the title Fix bug that caused &amp; to display and improve one-line rich-text fields Fix bug that caused &amp; to display and improve one-line rich-text fields Jun 11, 2024
@joemull joemull assigned ajrbyers and unassigned mauromsl Jun 11, 2024
@joemull joemull requested review from ajrbyers and removed request for mauromsl June 11, 2024 12:26
@joemull joemull requested a review from mauromsl June 11, 2024 12:27

@ajrbyers ajrbyers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one comment, looks good.

Comment thread src/core/forms/forms.py Outdated
@ajrbyers ajrbyers assigned joemull and unassigned ajrbyers and mauromsl Jun 11, 2024
@joemull joemull assigned ajrbyers and unassigned joemull Jun 11, 2024
@joemull joemull requested a review from ajrbyers June 11, 2024 13:28

@mauromsl mauromsl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very happy with this implementation. Well done @joemull.

As mentioned inline, it'd be good to fix any potentially corrupt journal title due to entity encoding (it is probably safe to only replace "&" but wouldn't harm to also fix encoded "<" and ">")

Couple minor comments regarding some class initialisers

Comment thread src/core/migrations/0089_update_setting_types.py Outdated
Comment thread src/core/migrations/0089_update_setting_types.py
Comment thread src/core/model_utils.py
Comment thread src/core/model_utils.py Outdated
Comment thread src/core/model_utils.py Outdated
@mauromsl mauromsl assigned joemull and unassigned mauromsl and ajrbyers Jun 11, 2024
@ajrbyers ajrbyers removed their assignment Jun 18, 2024
Comment thread src/core/model_utils.py
@mauromsl mauromsl merged commit 6918b72 into release_1_5_x Jun 19, 2024
@mauromsl mauromsl deleted the 4258-bleach-and-html-entities branch June 19, 2024 16:09
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.

HTML entities in bleached settings are not all rendered properly

3 participants