Fix rendering of dollar and single-quote Unicode character

This commit is contained in:
Alec Murphy
2022-05-20 12:21:09 -04:00
parent ec4ff3118a
commit da517831ab
+18 -2
View File
@@ -74,7 +74,9 @@ U0 @calculate_indents_for_sprites(CDoc *haystack_doc) {
}
}
U0 @sanitize_node_text(U8 *text) {
U8 *@sanitize_node_text(U8 *text) {
U8 *return_text = text;
U8 *old_text = text;
while (*text) {
switch (*text) {
case 0x11:
@@ -83,11 +85,25 @@ U0 @sanitize_node_text(U8 *text) {
case 0x12:
*text = '<';
break;
case 0x24: // dollar sign
return_text = CAlloc(StrLen(old_text) + 1);
StrCpy(return_text, old_text);
StrCpy(return_text + (text - old_text) + 1, text);
Free(old_text);
break;
case 0xe2:
if (*(text + 1)(U8 *) == 0x80 &&
*(text + 2)(U8 *) == 0x99) { // Single-quote
*text = '\'';
StrCpy(text + 1, text + 3);
}
break;
default:
break;
}
text++;
}
return return_text;
}
U0 NavigateTo(CDoc *doc, U8 *url) {
@@ -137,7 +153,7 @@ U0 @render_node_tree(CDoc *render_doc, CDoc *doc, Node *node) {
}
if (!StrICmp(node->tagName, "InternalTextNode")) {
@sanitize_node_text(node->text);
node->text = @sanitize_node_text(node->text);
if (StrICmp(node->parentNode->tagName, "option") &&
StrICmp(node->parentNode->tagName, "script") &&
StrICmp(node->parentNode->tagName, "style") &&