From 86709b2f1b3f85e92906617b6250983bcf926376 Mon Sep 17 00:00:00 2001 From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com> Date: Tue, 26 May 2026 16:06:17 +0300 Subject: [PATCH] Bug fixing --- dataList.go | 2 +- detailsView.go | 2 +- dropDownList.go | 2 +- editView.go | 2 +- tabsLayout.go | 2 +- textView.go | 4 ++-- utils.go | 16 ++++++++++++++++ 7 files changed, 23 insertions(+), 7 deletions(-) diff --git a/dataList.go b/dataList.go index 0efdd56..63e84b7 100644 --- a/dataList.go +++ b/dataList.go @@ -296,7 +296,7 @@ func dataListHtmlSubviews(view View, buffer *strings.Builder, normalizeItem func text = strings.ReplaceAll(text, "\n", `\n`) } buffer.WriteString(``) } buffer.WriteString(``) diff --git a/detailsView.go b/detailsView.go index 1320420..8216884 100644 --- a/detailsView.go +++ b/detailsView.go @@ -157,7 +157,7 @@ func (detailsView *detailsViewData) htmlSubviews(self View, buffer *strings.Buil } else { buffer.WriteString("") } - buffer.WriteString(value) + buffer.WriteString(textToHtml(value)) buffer.WriteString("") summary = true diff --git a/dropDownList.go b/dropDownList.go index 2949d84..b7a438c 100644 --- a/dropDownList.go +++ b/dropDownList.go @@ -230,7 +230,7 @@ func (list *dropDownListData) htmlSubviews(self View, buffer *strings.Builder) { item, _ = list.session.GetString(item) } - buffer.WriteString(item) + buffer.WriteString(textToHtml(item)) buffer.WriteString("") for _, index := range separators { if i == index { diff --git a/editView.go b/editView.go index 5634718..97075b9 100644 --- a/editView.go +++ b/editView.go @@ -298,7 +298,7 @@ func (edit *editViewData) htmlTag() string { func (edit *editViewData) htmlSubviews(self View, buffer *strings.Builder) { if GetEditViewType(edit) == MultiLineText { if text := GetText(edit); text != "" { - buffer.WriteString(text) + buffer.WriteString(textToHtml(text)) } } dataListHtmlSubviews(self, buffer, func(text string, session Session) string { diff --git a/tabsLayout.go b/tabsLayout.go index 1578c5c..486026d 100644 --- a/tabsLayout.go +++ b/tabsLayout.go @@ -671,7 +671,7 @@ func (tabsLayout *tabsLayoutData) htmlSubviews(self View, buffer *strings.Builde buffer.WriteString(view.htmlID()) buffer.WriteString(`-title"`) buffer.WriteString(titleStyle) - buffer.WriteString(title) + buffer.WriteString(textToHtml(title)) buffer.WriteString(``) close, ok := boolProperty(view, TabCloseButton, tabsLayout.session) diff --git a/textView.go b/textView.go index efcab65..bbc870a 100644 --- a/textView.go +++ b/textView.go @@ -100,11 +100,11 @@ func (textView *textViewData) setFunc(tag PropertyName, value any) []PropertyNam func (textView *textViewData) htmlSubviews(self View, buffer *strings.Builder) { if value := textView.getRaw(Text); value != nil { - if text, ok := value.(string); ok { + if text, ok := value.(string); ok && text != "" { if !GetNotTranslate(textView) { text, _ = textView.session.GetString(text) } - buffer.WriteString(text) + buffer.WriteString(textToHtml(text)) } } } diff --git a/utils.go b/utils.go index c45b834..94c6790 100644 --- a/utils.go +++ b/utils.go @@ -114,3 +114,19 @@ func InlineFileFromData(data []byte, mimeType string) string { return "data:" + mimeType + ";base64," + base64.StdEncoding.EncodeToString(data) } + +func textToHtml(text string) string { + replace := []struct{ old, new string }{ + {old: "&", new: "&"}, + {old: "\"", new: """}, + {old: "'", new: "'"}, + {old: "<", new: "<"}, + {old: ">", new: ">"}, + } + + for _, r := range replace { + text = strings.ReplaceAll(text, r.old, r.new) + } + + return text +}