diff --git a/common/component/src/main/ets/components/NoteContent.ets b/common/component/src/main/ets/components/NoteContent.ets index 8de6541817354cfbc892c98f5176a4fde5ee46ef..642575357bcb37c09637d485c42a6d7c8bd4e96c 100644 --- a/common/component/src/main/ets/components/NoteContent.ets +++ b/common/component/src/main/ets/components/NoteContent.ets @@ -106,9 +106,11 @@ export struct NoteContent { this.editContentFlag = true } LogUtil.info(TAG, "finish loadurl") - this.controllerShow.runJavaScript({ - script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" - }) + if (this.selectedNoteData) { + this.controllerShow.runJavaScript({ + script: "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')" + }) + } }) .zoomAccess(false) .height('70%') diff --git a/common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets b/common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets index 1a25f27f3a887e487c2b13bd28e67a22242149cc..5fd73c256ab56c66d57c793dc90ef9aae56f9990 100644 --- a/common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets +++ b/common/utils/src/main/ets/default/baseUtil/RdbStoreUtil.ets @@ -299,7 +299,13 @@ export default { LogUtil.info(TAG, "noteData.content_text is null or undefined") return imgNameArray } - let html = atob(noteData.content_text) + let base64regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/ + let html = "" + if (base64regex.test(noteData.content_text)) { + html = atob(noteData.content_text) + } else { + html = noteData.content_text + } if (html == undefined || html == null || html == "") { return imgNameArray } diff --git a/product/tablet/src/main/ets/MainAbility/MainAbility.ts b/product/tablet/src/main/ets/MainAbility/MainAbility.ts index e9ca97db90e3d195094ca11c90979bbebd69102e..4a3ff6e60ae9911a6cb34125b3cf123b3779b9b0 100644 --- a/product/tablet/src/main/ets/MainAbility/MainAbility.ts +++ b/product/tablet/src/main/ets/MainAbility/MainAbility.ts @@ -120,7 +120,13 @@ export default class MainAbility extends Ability { if (html == undefined || html == null || html == "") { return srcArray } - let realHtml = atob(html) + let base64regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/ + let realHtml = "" + if (base64regex.test(html)) { + realHtml = atob(html) + } else { + realHtml = html; + } let imgReg = /]+>/g let srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i let imgArray = realHtml.match(imgReg)