Repository: infernojs/inferno (js)

Issue:
Double text in SSR when started with quote symbols
**Observed Behaviour**

Trying this code:
```js
const InfernoServer = require("inferno-server")
const createElement = require("inferno-create-element")
InfernoServer.renderToString(createElement('div', {}, '"test'))
```
Gives: 
```html
<div>"test&quot;test</div>
```
Text doubles when started with `"` or `&`  

**Expected Current Behaviour**

Should be
```html
<div>&quot;test</div>
```


**Inferno Metadata**
Was tested here: https://npm.runkit.com/


Pull request description:
Issue #1191: Double text in SSR when started with quote symbols
Closes #1191
Fixed and added test for this issue

Patch:
diff --git a/packages/inferno-server/src/utils.ts b/packages/inferno-server/src/utils.ts
index d98832fde..57b88d821 100644
--- a/packages/inferno-server/src/utils.ts
+++ b/packages/inferno-server/src/utils.ts
@@ -3,8 +3,8 @@
  */ /** TypeDoc Comment */
 
 export function escapeText(text: string): string {
-  let result = text;
-  let escape: string = "";
+  let result = "";
+  let escape = "";
   let start = 0;
   let i;
   for (i = 0; i < text.length; i++) {
@@ -37,10 +37,7 @@ export function escapeText(text: string): string {
     result += escape;
     start = i + 1;
   }
-  if (start && i !== start) {
-    return result + text.slice(start, i);
-  }
-  return result;
+  return result + text.slice(start, i);
 }
 
 const uppercasePattern = /[A-Z]/g;


Test patch:
diff --git a/packages/inferno-server/__tests__/creation.spec.jsx b/packages/inferno-server/__tests__/creation.spec.jsx
index 647de8198..f43d3122c 100644
--- a/packages/inferno-server/__tests__/creation.spec.jsx
+++ b/packages/inferno-server/__tests__/creation.spec.jsx
@@ -46,6 +46,11 @@ describe("SSR Creation (JSX)", () => {
         </div>,
       result: "<div>Hello world, <!---->1<!---->2<!---->3</div>"
     },
+    {
+      description: "should render text with escaped symbols",
+      template: () => <div>"Hello world"</div>,
+      result: "<div>&quot;Hello world&quot;</div>"
+    },
     {
       description: "should render a stateless component with comments",
       template: () =>