Skip to content

External links do not have target=_blank attribute #1467

Closed
@Fab1en

Description

@Fab1en

Bug Report

When using homepage to point to an external file, the default configuration automatically adds rel="noopener" and target="_blank" attributes to external links. But then, DOMPurify sanitizer removes the target attribute as it is not in the white list. This completely prevent the opening of external links in history router mode.

Steps to reproduce

Just point to an external file as your homepage :

window.$docsify = {
      homepage: 'https://raw.githubusercontent.com/docsifyjs/docsify/develop/docs/README.md',
}

What is current behaviour

generated HTML for external link is missing "target" attribute :

<li>Support server-side rendering (<a rel="noopener" href="https://github.com/docsifyjs/docsify-ssr-demo">example</a>)</li>

What is the expected behaviour

target attribute should be present
generated HTML for external link is missing "target" attribute :

<li>Support server-side rendering (<a rel="noopener" target="_blank" href="https://github.com/docsifyjs/docsify-ssr-demo">example</a>)</li>

Other relevant information

  • Bug does still occur when all/other plugins are disabled?

  • Your OS: Ubuntu

  • Node.js version:

  • npm/yarn version:

  • Browser version:

  • Docsify version: 4.11.6

  • Docsify plugins:

Please create a reproducible sandbox

Edit 307qqv236

Mention the docsify version in which this bug was not present (if any)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions