Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable to copy HTML Formatted Link #591

Closed
wants to merge 1 commit into from

Conversation

tmsanrinsha
Copy link
Contributor

I created a mapping, yankDocumentUrlHtmlFormatted.
This feature is useful to paste to rich editor.

ref. https://stackoverflow.com/questions/25657626/how-to-copy-html-formatted-text-on-to-clipboard-from-google-chrome-extension/25662380#25662380

@1995eaton
Copy link
Owner

1995eaton commented Nov 13, 2017

I don't want to merge this PR because of the possible vulnerability created by using innerHTML. It is possible to include HTML tags in the <title> tag, which means malicious HTML in the title may pose a security issue. No scripts will be able to execute due to the Content Security Policy for Chrome extensions, but it still may be risky (see here).

However, I managed to come up with something you could add to your cvimrc that seems to do the same thing as your PR.

yankDocumentUrlHtmlFormatted -> {{
    let title = document.title
        .replace(/&/g, '&amp;')
        .replace(/</g, '&lt;')
        .replace(/>/g, '&gt;');

    let text = `<a href="${document.URL}">${title}</a>`;

    RUNTIME('copy', {text});
    Status.setMessage(text, 2);
}}
map yf :call yankDocumentUrlHtmlFormatted<CR>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants