Problems with link rendering in vue

as in some forums, entering a link will render as a hyperlink, but entering a html snippet will not render as html.

my own vue development, simply replacing the matching link with a tag parsing with v-html will have security problems.

Xiaobai, let"s ask for some ideas

Jul.23,2021

first of all, the user enters the string, and the page finally outputs the Vue component. All you have to do is implement a process of converting the string to VNode List (dynamic component).

then, you can tell whether the user enters a URL or a HTML,. For URL, replace it with or a linked component; for HTML,sanitize, just output the string. This process has nothing to do with v-html.

of course, if the final display of the page does not involve Vue, it is nothing more than a matter of converting it all to HTML strings, and the process is roughly the same. Whether it is safe or not depends on how you sanitize.

Menu