Properly escape HTML in every Scribe actions
In recent commits I separated how we could add text in the editor. So we need to escape HTML in both method that add text: insertTextInEditor and setTextInEditor. I had to extract the HTML escape part of convertTextContentToHtmlContent because when using setTextInEditor we do not need to convert \n to <br>.
This commit is contained in:
+7
-4
@@ -36,7 +36,8 @@ extension HandleAiScribeInComposerExtension on ComposerController {
|
||||
|
||||
Future<void> insertTextInEditor(String text) async {
|
||||
try {
|
||||
final htmlContent = StringConvert.convertTextContentToHtmlContent(text);
|
||||
final escapedText = StringConvert.escapeTextContent(text);
|
||||
final htmlContent = StringConvert.convertTextContentToHtmlContent(escapedText);
|
||||
|
||||
if (PlatformInfo.isWeb) {
|
||||
await richTextWebController?.editorController.evaluateJavascriptWeb(
|
||||
@@ -55,13 +56,15 @@ extension HandleAiScribeInComposerExtension on ComposerController {
|
||||
|
||||
Future<void> setTextInEditor(String text) async {
|
||||
try {
|
||||
final escapedText = StringConvert.escapeTextContent(text);
|
||||
|
||||
if (PlatformInfo.isWeb) {
|
||||
richTextWebController?.editorController.setText(text);
|
||||
richTextWebController?.editorController.setText(escapedText);
|
||||
} else {
|
||||
await richTextMobileTabletController?.htmlEditorApi?.setText(text);
|
||||
await richTextMobileTabletController?.htmlEditorApi?.setText(escapedText);
|
||||
}
|
||||
} catch (e) {
|
||||
logWarning('$runtimeType::insertTextInEditor:Exception = $e');
|
||||
logWarning('$runtimeType::setTextInEditor:Exception = $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user