Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple_format with blank wrapper_tag option returns nonsence HTML tag #44948

Closed
JunichiIto opened this issue Apr 24, 2022 · 1 comment · Fixed by #49120
Closed

simple_format with blank wrapper_tag option returns nonsence HTML tag #44948

JunichiIto opened this issue Apr 24, 2022 · 1 comment · Fixed by #49120

Comments

@JunichiIto
Copy link
Contributor

Steps to reproduce

Use simple_format method with blank wrapper_tag option.

simple_format(nil, {}, { wrapper_tag: "" })

Some people try to remove wrapper tag from the result of simple_format method, so they give an empty string to wrapper_tag option.

Expected behavior

It should fallback to p tag:

"<p></p>"

Or return no wrapper tags:

""

Or raise ArgumentError.

Actual behavior

It returns the following HTML:

"<></>"

But it is nonsense.

System configuration

Rails version: 7.0.2.3

Ruby version: 3.1.1

@akhilgkrishnan
Copy link
Member

Made a partial fix in PR #49120 for handling the nil case. But as per the discussion #49120 (comment), we finally agreed to have validation in content_tag for handling different scenarios including the empty string "" case and raising an error.

I'm working on that and creating another PR handling the validation and raising an error for content_tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants