@@ -2579,6 +2579,12 @@ void RichTextLabel::_fetch_item_fx_stack(Item *p_item, Vector<ItemFX *> &r_stack
2579
2579
}
2580
2580
}
2581
2581
2582
+ void RichTextLabel::_normalize_subtags (Vector<String> &subtags) {
2583
+ for (String &subtag : subtags) {
2584
+ subtag = subtag.unquote ();
2585
+ }
2586
+ }
2587
+
2582
2588
bool RichTextLabel::_find_meta (Item *p_item, Variant *r_meta, ItemMeta **r_item) {
2583
2589
Item *item = p_item;
2584
2590
@@ -3718,7 +3724,7 @@ void RichTextLabel::append_text(const String &p_bbcode) {
3718
3724
const String &expr = split_tag_block[i];
3719
3725
int value_pos = expr.find (" =" );
3720
3726
if (value_pos > -1 ) {
3721
- bbcode_options[expr.substr (0 , value_pos)] = expr.substr (value_pos + 1 );
3727
+ bbcode_options[expr.substr (0 , value_pos)] = expr.substr (value_pos + 1 ). unquote () ;
3722
3728
}
3723
3729
}
3724
3730
} else {
@@ -3827,6 +3833,8 @@ void RichTextLabel::append_text(const String &p_bbcode) {
3827
3833
tag_stack.push_front (tag);
3828
3834
} else if (tag.begins_with (" table=" )) {
3829
3835
Vector<String> subtag = tag.substr (6 , tag.length ()).split (" ," );
3836
+ _normalize_subtags (subtag);
3837
+
3830
3838
int columns = subtag[0 ].to_int ();
3831
3839
if (columns < 1 ) {
3832
3840
columns = 1 ;
@@ -3886,9 +3894,12 @@ void RichTextLabel::append_text(const String &p_bbcode) {
3886
3894
tag_stack.push_front (" cell" );
3887
3895
} else if (tag.begins_with (" cell " )) {
3888
3896
Vector<String> subtag = tag.substr (5 , tag.length ()).split (" " );
3897
+ _normalize_subtags (subtag);
3889
3898
3890
3899
for (int i = 0 ; i < subtag.size (); i++) {
3891
3900
Vector<String> subtag_a = subtag[i].split (" =" );
3901
+ _normalize_subtags (subtag_a);
3902
+
3892
3903
if (subtag_a.size () == 2 ) {
3893
3904
if (subtag_a[0 ] == " expand" ) {
3894
3905
int ratio = subtag_a[1 ].to_int ();
@@ -3903,12 +3914,16 @@ void RichTextLabel::append_text(const String &p_bbcode) {
3903
3914
const Color fallback_color = Color (0 , 0 , 0 , 0 );
3904
3915
for (int i = 0 ; i < subtag.size (); i++) {
3905
3916
Vector<String> subtag_a = subtag[i].split (" =" );
3917
+ _normalize_subtags (subtag_a);
3918
+
3906
3919
if (subtag_a.size () == 2 ) {
3907
3920
if (subtag_a[0 ] == " border" ) {
3908
3921
Color color = Color::from_string (subtag_a[1 ], fallback_color);
3909
3922
set_cell_border_color (color);
3910
3923
} else if (subtag_a[0 ] == " bg" ) {
3911
3924
Vector<String> subtag_b = subtag_a[1 ].split (" ," );
3925
+ _normalize_subtags (subtag_b);
3926
+
3912
3927
if (subtag_b.size () == 2 ) {
3913
3928
Color color1 = Color::from_string (subtag_b[0 ], fallback_color);
3914
3929
Color color2 = Color::from_string (subtag_b[1 ], fallback_color);
@@ -3920,6 +3935,8 @@ void RichTextLabel::append_text(const String &p_bbcode) {
3920
3935
}
3921
3936
} else if (subtag_a[0 ] == " padding" ) {
3922
3937
Vector<String> subtag_b = subtag_a[1 ].split (" ," );
3938
+ _normalize_subtags (subtag_b);
3939
+
3923
3940
if (subtag_b.size () == 4 ) {
3924
3941
set_cell_padding (Rect2 (subtag_b[0 ].to_float (), subtag_b[1 ].to_float (), subtag_b[2 ].to_float (), subtag_b[3 ].to_float ()));
3925
3942
}
@@ -4056,12 +4073,16 @@ void RichTextLabel::append_text(const String &p_bbcode) {
4056
4073
tag_stack.push_front (" p" );
4057
4074
} else if (tag.begins_with (" p " )) {
4058
4075
Vector<String> subtag = tag.substr (2 , tag.length ()).split (" " );
4076
+ _normalize_subtags (subtag);
4077
+
4059
4078
HorizontalAlignment alignment = HORIZONTAL_ALIGNMENT_LEFT;
4060
4079
Control::TextDirection dir = Control::TEXT_DIRECTION_INHERITED;
4061
4080
String lang;
4062
4081
TextServer::StructuredTextParser st_parser_type = TextServer::STRUCTURED_TEXT_DEFAULT;
4063
4082
for (int i = 0 ; i < subtag.size (); i++) {
4064
4083
Vector<String> subtag_a = subtag[i].split (" =" );
4084
+ _normalize_subtags (subtag_a);
4085
+
4065
4086
if (subtag_a.size () == 2 ) {
4066
4087
if (subtag_a[0 ] == " align" ) {
4067
4088
if (subtag_a[1 ] == " l" || subtag_a[1 ] == " left" ) {
@@ -4110,24 +4131,26 @@ void RichTextLabel::append_text(const String &p_bbcode) {
4110
4131
if (end == -1 ) {
4111
4132
end = p_bbcode.length ();
4112
4133
}
4113
- String url = p_bbcode.substr (brk_end + 1 , end - brk_end - 1 );
4134
+ String url = p_bbcode.substr (brk_end + 1 , end - brk_end - 1 ). unquote () ;
4114
4135
push_meta (url);
4115
4136
4116
4137
pos = brk_end + 1 ;
4117
4138
tag_stack.push_front (tag);
4118
4139
4119
4140
} else if (tag.begins_with (" url=" )) {
4120
- String url = tag.substr (4 , tag.length ());
4141
+ String url = tag.substr (4 , tag.length ()). unquote () ;
4121
4142
push_meta (url);
4122
4143
pos = brk_end + 1 ;
4123
4144
tag_stack.push_front (" url" );
4124
4145
} else if (tag.begins_with (" hint=" )) {
4125
- String description = tag.substr (5 , tag.length ());
4146
+ String description = tag.substr (5 , tag.length ()). unquote () ;
4126
4147
push_hint (description);
4127
4148
pos = brk_end + 1 ;
4128
4149
tag_stack.push_front (" hint" );
4129
4150
} else if (tag.begins_with (" dropcap" )) {
4130
4151
Vector<String> subtag = tag.substr (5 , tag.length ()).split (" " );
4152
+ _normalize_subtags (subtag);
4153
+
4131
4154
int fs = theme_cache.normal_font_size * 3 ;
4132
4155
Ref<Font> f = theme_cache.normal_font ;
4133
4156
Color color = theme_cache.default_color ;
@@ -4137,6 +4160,8 @@ void RichTextLabel::append_text(const String &p_bbcode) {
4137
4160
4138
4161
for (int i = 0 ; i < subtag.size (); i++) {
4139
4162
Vector<String> subtag_a = subtag[i].split (" =" );
4163
+ _normalize_subtags (subtag_a);
4164
+
4140
4165
if (subtag_a.size () == 2 ) {
4141
4166
if (subtag_a[0 ] == " font" || subtag_a[0 ] == " f" ) {
4142
4167
String fnt = subtag_a[1 ];
@@ -4148,6 +4173,8 @@ void RichTextLabel::append_text(const String &p_bbcode) {
4148
4173
fs = subtag_a[1 ].to_int ();
4149
4174
} else if (subtag_a[0 ] == " margins" ) {
4150
4175
Vector<String> subtag_b = subtag_a[1 ].split (" ," );
4176
+ _normalize_subtags (subtag_b);
4177
+
4151
4178
if (subtag_b.size () == 4 ) {
4152
4179
dropcap_margins.position .x = subtag_b[0 ].to_float ();
4153
4180
dropcap_margins.position .y = subtag_b[1 ].to_float ();
@@ -4178,6 +4205,8 @@ void RichTextLabel::append_text(const String &p_bbcode) {
4178
4205
int alignment = INLINE_ALIGNMENT_CENTER;
4179
4206
if (tag.begins_with (" img=" )) {
4180
4207
Vector<String> subtag = tag.substr (4 , tag.length ()).split (" ," );
4208
+ _normalize_subtags (subtag);
4209
+
4181
4210
if (subtag.size () > 1 ) {
4182
4211
if (subtag[0 ] == " top" || subtag[0 ] == " t" ) {
4183
4212
alignment = INLINE_ALIGNMENT_TOP_TO;
@@ -4261,14 +4290,14 @@ void RichTextLabel::append_text(const String &p_bbcode) {
4261
4290
pos = end;
4262
4291
tag_stack.push_front (bbcode_name);
4263
4292
} else if (tag.begins_with (" color=" )) {
4264
- String color_str = tag.substr (6 , tag.length ());
4293
+ String color_str = tag.substr (6 , tag.length ()). unquote () ;
4265
4294
Color color = Color::from_string (color_str, theme_cache.default_color );
4266
4295
push_color (color);
4267
4296
pos = brk_end + 1 ;
4268
4297
tag_stack.push_front (" color" );
4269
4298
4270
4299
} else if (tag.begins_with (" outline_color=" )) {
4271
- String color_str = tag.substr (14 , tag.length ());
4300
+ String color_str = tag.substr (14 , tag.length ()). unquote () ;
4272
4301
Color color = Color::from_string (color_str, theme_cache.default_color );
4273
4302
push_outline_color (color);
4274
4303
pos = brk_end + 1 ;
@@ -4284,6 +4313,8 @@ void RichTextLabel::append_text(const String &p_bbcode) {
4284
4313
int value_pos = tag.find (" =" );
4285
4314
String fnt_ftr = tag.substr (value_pos + 1 );
4286
4315
Vector<String> subtag = fnt_ftr.split (" ," );
4316
+ _normalize_subtags (subtag);
4317
+
4287
4318
if (subtag.size () > 0 ) {
4288
4319
Ref<Font> font = theme_cache.normal_font ;
4289
4320
DefaultFont def_font = NORMAL_FONT;
@@ -4298,6 +4329,8 @@ void RichTextLabel::append_text(const String &p_bbcode) {
4298
4329
Dictionary features;
4299
4330
for (int i = 0 ; i < subtag.size (); i++) {
4300
4331
Vector<String> subtag_a = subtag[i].split (" =" );
4332
+ _normalize_subtags (subtag_a);
4333
+
4301
4334
if (subtag_a.size () == 2 ) {
4302
4335
features[TS->name_to_tag (subtag_a[0 ])] = subtag_a[1 ].to_int ();
4303
4336
} else if (subtag_a.size () == 1 ) {
@@ -4321,7 +4354,7 @@ void RichTextLabel::append_text(const String &p_bbcode) {
4321
4354
tag_stack.push_front (tag.substr (0 , value_pos));
4322
4355
4323
4356
} else if (tag.begins_with (" font=" )) {
4324
- String fnt = tag.substr (5 , tag.length ());
4357
+ String fnt = tag.substr (5 , tag.length ()). unquote () ;
4325
4358
4326
4359
Ref<Font> fc = ResourceLoader::load (fnt, " Font" );
4327
4360
if (fc.is_valid ()) {
@@ -4333,6 +4366,7 @@ void RichTextLabel::append_text(const String &p_bbcode) {
4333
4366
4334
4367
} else if (tag.begins_with (" font " )) {
4335
4368
Vector<String> subtag = tag.substr (2 , tag.length ()).split (" " );
4369
+ _normalize_subtags (subtag);
4336
4370
4337
4371
Ref<Font> font = theme_cache.normal_font ;
4338
4372
DefaultFont def_font = NORMAL_FONT;
@@ -4351,6 +4385,8 @@ void RichTextLabel::append_text(const String &p_bbcode) {
4351
4385
int fnt_size = -1 ;
4352
4386
for (int i = 1 ; i < subtag.size (); i++) {
4353
4387
Vector<String> subtag_a = subtag[i].split (" =" , true , 2 );
4388
+ _normalize_subtags (subtag_a);
4389
+
4354
4390
if (subtag_a.size () == 2 ) {
4355
4391
if (subtag_a[0 ] == " name" || subtag_a[0 ] == " n" ) {
4356
4392
String fnt = subtag_a[1 ];
@@ -4388,6 +4424,8 @@ void RichTextLabel::append_text(const String &p_bbcode) {
4388
4424
Vector<String> variation_tags = subtag_a[1 ].split (" ," );
4389
4425
for (int j = 0 ; j < variation_tags.size (); j++) {
4390
4426
Vector<String> subtag_b = variation_tags[j].split (" =" );
4427
+ _normalize_subtags (subtag_b);
4428
+
4391
4429
if (subtag_b.size () == 2 ) {
4392
4430
variations[TS->name_to_tag (subtag_b[0 ])] = subtag_b[1 ].to_float ();
4393
4431
}
@@ -4400,6 +4438,8 @@ void RichTextLabel::append_text(const String &p_bbcode) {
4400
4438
Vector<String> feature_tags = subtag_a[1 ].split (" ," );
4401
4439
for (int j = 0 ; j < feature_tags.size (); j++) {
4402
4440
Vector<String> subtag_b = feature_tags[j].split (" =" );
4441
+ _normalize_subtags (subtag_b);
4442
+
4403
4443
if (subtag_b.size () == 2 ) {
4404
4444
features[TS->name_to_tag (subtag_b[0 ])] = subtag_b[1 ].to_float ();
4405
4445
} else if (subtag_b.size () == 1 ) {
@@ -4540,15 +4580,15 @@ void RichTextLabel::append_text(const String &p_bbcode) {
4540
4580
set_process_internal (true );
4541
4581
4542
4582
} else if (tag.begins_with (" bgcolor=" )) {
4543
- String color_str = tag.substr (8 , tag.length ());
4583
+ String color_str = tag.substr (8 , tag.length ()). unquote () ;
4544
4584
Color color = Color::from_string (color_str, theme_cache.default_color );
4545
4585
4546
4586
push_bgcolor (color);
4547
4587
pos = brk_end + 1 ;
4548
4588
tag_stack.push_front (" bgcolor" );
4549
4589
4550
4590
} else if (tag.begins_with (" fgcolor=" )) {
4551
- String color_str = tag.substr (8 , tag.length ());
4591
+ String color_str = tag.substr (8 , tag.length ()). unquote () ;
4552
4592
Color color = Color::from_string (color_str, theme_cache.default_color );
4553
4593
4554
4594
push_fgcolor (color);
0 commit comments