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

Quotes in RichTextLabel BBCode string arguments are passed as-is, which is inconsistent with string arguments elsewhere #75501

Closed
Calinou opened this issue Mar 30, 2023 · 0 comments · Fixed by #75622

Comments

@Calinou
Copy link
Member

Calinou commented Mar 30, 2023

Godot version

4.0.1.stable

System information

Fedora 37, GeForce RTX 4090 (NVIDIA 525.89.02)

Issue description

The following BBCode in a RichTextLabel:

[p align=center]p align center[/p]

[p align="center"]p align "center"[/p]

[p align='center']p align 'center'[/p]

Results in:

image

I'd expect all 3 to be center-aligned, parsing the align argument's value as center and not "center" or 'center' with the quotes. This is the behavior found in any programming language, HTML/CSS, etc. This can cause difficult-to-diagnose issues as to why string parameters aren't behaving as expected in BBCode, especially when file paths are involved.

We should handle string paths with quotes (single or double) in RichTextLabel to avoid this kind of issue. It should be as simple as calling .trim_prefix("\"").trim_suffix("\"").trim_prefix("'").trim_suffix("'") when parsing a string parameter in RichTextLabel's BBCode parser.

See godotengine/godot-docs#6574 (comment) where this issue was originally encountered.

Modifying this behavior is technically a breaking change, but the chance that someone is relying on the current behavior (string arguments containing their beginning/end quotes) is very low.

Steps to reproduce

  • Add a RichTextLabel node with BBCode enabled.
  • Write [p align="center"]p align "center"[/p] within the Text property.
  • Notice how the label isn't centered because center is surrounded by quotes.

Minimal reproduction project

test_richtextlabel_string_quotes.zip

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

Successfully merging a pull request may close this issue.

2 participants