Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • G gitlabhq1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gpt
  • large_projects
  • gitlabhq1
  • Merge requests
  • !8007

Merged
Created Oct 10, 2014 by Administrator@rootOwner

Allow HTML tags in user Markdown input

  • Overview 44
  • Commits 9
  • Changes 5

Created by: mr-vinn

This change fixes #7066 (closed), and issues #147, #408 and #476 from gitlab.com.

The Markdown parser currently uses Redcarpet's :filter_html option, which removes all HTML tags from user input. The parser also calls ActionView's #sanitize method, which removes HTML tags and attributes that are not whitelisted.

GitLab's Markdown documentation says that inline HTML should be allowed, which seems incompatible with the :filter_html option. This change disables that option to allow safe tags from user input to appear in the rendered HTML.

However, relying on #sanitize at the end of parsing doesn't handle javascript in tag attributes correctly. For example, this input:

<a href="javascript:alert('foo')">link text</a>

is rendered as:

<a href="/namespace101/gitlabhq/blob/markdown/javascript:alert(&#39;foo&#39;)">link text</a>

To handle javascript in attributes, I added a call to #sanitize before parsing relative links. This results in the correctly sanitized output:

<a>link text</a>
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: github/fork/mr-vinn/markdown-tags