Kaynağa Gözat

Replace U+00A0 with real spaces before sending text (#745)

Fixes #731.
Danilo Bargen 6 yıl önce
ebeveyn
işleme
5037ae7a40
1 değiştirilmiş dosya ile 10 ekleme ve 1 silme
  1. 10 1
      src/directives/compose_area.ts

+ 10 - 1
src/directives/compose_area.ts

@@ -170,7 +170,16 @@ export default [
                 //
                 // Emoji images are converted to their alt text in this process.
                 function submitText(): Promise<any> {
-                    const text = extractText(composeDiv[0], logAdapter($log.warn, logTag));
+                    const rawText = extractText(composeDiv[0], logAdapter($log.warn, logTag));
+
+                    // Due to #731, and the hack introduced in #706, the
+                    // extracted text may contain non-breaking spaces (U+00A0).
+                    // Replace them with actual whitespace to avoid strange
+                    // behavior when submitting the text.
+                    //
+                    // TODO: Remove this once we have a compose area rewrite and can
+                    // fix the actual bug.
+                    const text = rawText.replace(/\u00A0/g, ' ');
 
                     return new Promise((resolve, reject) => {
                         const submitTexts = (strings: string[]) => {