Bug fixing

This commit is contained in:
anoshenko 2022-10-29 21:08:51 +03:00
parent 45c798d14c
commit 8216ce192a
4 changed files with 7 additions and 24 deletions

View File

@ -440,7 +440,7 @@ func (edit *editViewData) htmlProperties(self View, buffer *strings.Builder) {
if strings.ContainsRune(text, '"') { if strings.ContainsRune(text, '"') {
text = strings.ReplaceAll(text, `"`, `"`) text = strings.ReplaceAll(text, `"`, `"`)
} }
return textToJS(text) return text
} }
if hint := GetHint(edit); hint != "" { 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) { func (edit *editViewData) htmlSubviews(self View, buffer *strings.Builder) {
if GetEditViewType(edit) == MultiLineText { if GetEditViewType(edit) == MultiLineText {
buffer.WriteString(textToJS(GetText(edit))) buffer.WriteString(GetText(edit))
} }
} }

View File

@ -246,7 +246,7 @@ func (imageView *imageViewData) htmlProperties(self View, buffer *strings.Builde
if text := GetImageViewAltText(imageView); text != "" { if text := GetImageViewAltText(imageView); text != "" {
buffer.WriteString(` alt="`) buffer.WriteString(` alt="`)
buffer.WriteString(textToJS(text)) buffer.WriteString(text)
buffer.WriteString(`"`) buffer.WriteString(`"`)
} }

View File

@ -1027,7 +1027,7 @@ func (table *tableViewData) htmlSubviews(self View, buffer *strings.Builder) {
switch value := adapter.Cell(row, column).(type) { switch value := adapter.Cell(row, column).(type) {
case string: case string:
buffer.WriteString(textToJS(value)) buffer.WriteString(value)
case View: case View:
viewHTML(value, buffer) viewHTML(value, buffer)
@ -1051,10 +1051,10 @@ func (table *tableViewData) htmlSubviews(self View, buffer *strings.Builder) {
} }
case fmt.Stringer: case fmt.Stringer:
buffer.WriteString(textToJS(value.String())) buffer.WriteString(value.String())
case rune: case rune:
buffer.WriteString(textToJS(string(value))) buffer.WriteString(string(value))
case float32: case float32:
buffer.WriteString(fmt.Sprintf("%g", float64(value))) buffer.WriteString(fmt.Sprintf("%g", float64(value)))

View File

@ -135,30 +135,13 @@ func (textView *textViewData) textOverflowUpdated() {
updateCSSProperty(textView.htmlID(), TextOverflow, "", session) 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) { func (textView *textViewData) htmlSubviews(self View, buffer *strings.Builder) {
if value := textView.getRaw(Text); value != nil { if value := textView.getRaw(Text); value != nil {
if text, ok := value.(string); ok { if text, ok := value.(string); ok {
if !GetNotTranslate(textView) { if !GetNotTranslate(textView) {
text, _ = textView.session.GetString(text) text, _ = textView.session.GetString(text)
} }
buffer.WriteString(textToJS(text)) buffer.WriteString(text)
} }
} }
} }