You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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:
Results in:
I'd expect all 3 to be center-aligned, parsing the
align
argument's value ascenter
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
[p align="center"]p align "center"[/p]
within the Text property.center
is surrounded by quotes.Minimal reproduction project
test_richtextlabel_string_quotes.zip
The text was updated successfully, but these errors were encountered: