From 8216ce192aaafabf172dd16b7eb36ff27ad45771 Mon Sep 17 00:00:00 2001 From: anoshenko Date: Sat, 29 Oct 2022 21:08:51 +0300 Subject: [PATCH] Bug fixing --- editView.go | 4 ++-- imageView.go | 2 +- tableView.go | 6 +++--- textView.go | 19 +------------------ 4 files changed, 7 insertions(+), 24 deletions(-) diff --git a/editView.go b/editView.go index 3acd0db..aaad03e 100644 --- a/editView.go +++ b/editView.go @@ -440,7 +440,7 @@ func (edit *editViewData) htmlProperties(self View, buffer *strings.Builder) { if strings.ContainsRune(text, '"') { text = strings.ReplaceAll(text, `"`, `"`) } - return textToJS(text) + return text } if hint := GetHint(edit); hint != "" { @@ -474,7 +474,7 @@ func (edit *editViewData) htmlDisabledProperties(self View, buffer *strings.Buil func (edit *editViewData) htmlSubviews(self View, buffer *strings.Builder) { if GetEditViewType(edit) == MultiLineText { - buffer.WriteString(textToJS(GetText(edit))) + buffer.WriteString(GetText(edit)) } } diff --git a/imageView.go b/imageView.go index 4ed1ae4..b95df50 100644 --- a/imageView.go +++ b/imageView.go @@ -246,7 +246,7 @@ func (imageView *imageViewData) htmlProperties(self View, buffer *strings.Builde if text := GetImageViewAltText(imageView); text != "" { buffer.WriteString(` alt="`) - buffer.WriteString(textToJS(text)) + buffer.WriteString(text) buffer.WriteString(`"`) } diff --git a/tableView.go b/tableView.go index edd5335..8f95587 100644 --- a/tableView.go +++ b/tableView.go @@ -1027,7 +1027,7 @@ func (table *tableViewData) htmlSubviews(self View, buffer *strings.Builder) { switch value := adapter.Cell(row, column).(type) { case string: - buffer.WriteString(textToJS(value)) + buffer.WriteString(value) case View: viewHTML(value, buffer) @@ -1051,10 +1051,10 @@ func (table *tableViewData) htmlSubviews(self View, buffer *strings.Builder) { } case fmt.Stringer: - buffer.WriteString(textToJS(value.String())) + buffer.WriteString(value.String()) case rune: - buffer.WriteString(textToJS(string(value))) + buffer.WriteString(string(value)) case float32: buffer.WriteString(fmt.Sprintf("%g", float64(value))) diff --git a/textView.go b/textView.go index dac9f9c..70d3336 100644 --- a/textView.go +++ b/textView.go @@ -135,30 +135,13 @@ func (textView *textViewData) textOverflowUpdated() { updateCSSProperty(textView.htmlID(), TextOverflow, "", session) } -func textToJS(text string) string { - for _, ch := range []struct{ old, new string }{ - {old: "\\", new: `\\`}, - {old: "\"", new: `\"`}, - {old: "'", new: `\'`}, - {old: "\n", new: `\n`}, - {old: "\r", new: `\r`}, - {old: "\t", new: `\t`}, - {old: "\x00", new: `\x00`}, - } { - if strings.Contains(text, ch.old) { - text = strings.ReplaceAll(text, ch.old, ch.new) - } - } - return text -} - func (textView *textViewData) htmlSubviews(self View, buffer *strings.Builder) { if value := textView.getRaw(Text); value != nil { if text, ok := value.(string); ok { if !GetNotTranslate(textView) { text, _ = textView.session.GetString(text) } - buffer.WriteString(textToJS(text)) + buffer.WriteString(text) } } }