Skip to content

Commit

Permalink
fixes non-HTML angle brackets in text data
Browse files Browse the repository at this point in the history
  • Loading branch information
davelandry committed Feb 12, 2019
1 parent bc6a453 commit dbfd212
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/TextBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,13 @@ export default class TextBox extends BaseClass {

text
[that._html ? "html" : "text"](t => trimRight(t)
.replace(/(<[^>^\/]+>)([^<^>]+)$/g, (str, a, b) => `${a}${b}${a.replace("<", "</")}`)
.replace(/^([^<^>]+)(<\/[^>]+>)/g, (str, a, b) => `${b.replace("</", "<")}${a}${b}`)
.replace(/<([^A-z^/]+)/g, (str, a) => `&lt;${a}`).replace(/<$/g, "&lt;") // replaces all non-HTML left angle brackets with escaped entity
.replace(/(<[^>^\/]+>)([^<^>]+)$/g, (str, a, b) => `${a}${b}${a.replace("<", "</")}`) // ands end tag to lines before mid-HTML break
.replace(/^([^<^>]+)(<\/[^>]+>)/g, (str, a, b) => `${b.replace("</", "<")}${a}${b}`) // ands start tag to lines after mid-HTML break
.replace(/<([A-z]+)[^>]*>([^<^>]+)<\/[^>]+>/g, (str, a, b) => {
const tag = tagLookup[a] ? `<tspan style="${tagLookup[a]}">` : "";
return `${tag.length ? tag : ""}${b}${tag.length ? "</tspan>" : ""}`;
})
);
}));

}

Expand Down

0 comments on commit dbfd212

Please sign in to comment.