Commit Graph
120 Commits
Author SHA1 Message Date
Stan Hu 8820785c8f Fix emoji URLs in Markdown when relative_url_root is used
Also adds the ability to run rspecs with relative_url_defined on the enviornment. For example:

RELATIVE_URL_ROOT=/gitlab rspec

Closes #1728
2015-09-06 09:46:10 -07:00
Robert Speicher 08ca941186 Move REDCARPET_OPTIONS to a private method
There wasn't really a reason to have them as a constant, and we were
getting "already defined" warnings which are always annoying.
2015-08-31 16:22:34 -04:00
Robert Speicher 8e7111f79d Reference filters no longer take a custom class context option 2015-08-27 15:36:26 -07:00
Robert Speicher 4340dd3eeb Decouple Gitlab::Markdown from the GitlabMarkdownHelper
This module is now the sole source of knowledge for *how* we render
Markdown (and GFM).
2015-08-27 14:17:26 -07:00
Robert Speicher 907860ed3d Remove the gfm_with_options helper
It was redundant because `gfm` also took options.
2015-08-12 23:32:16 -04:00
Kamil Trzcinski a34c61d9c6 Reuse HTML Pipeline object in Markdown parser
The patches reduces pressure on GC and reduces markdown processing time
2015-06-30 13:59:27 +02:00
Robert Speicher 023dd2907b Add a pipeline context option for SanitizationFilter
When this option is `:description`, we use a more restrictive whitelist.
This is used for Project and Group description fields.
2015-06-02 13:04:10 -04:00
Robert Speicher 7424d2fa5b Add ExternalLinkFilter to Markdown pipeline
Forces a `rel="nofollow"` attribute on all external links.
2015-05-27 15:39:08 -04:00
Robert Speicher 8ee382087d Subclass TaskList::Filter to fix a bug
Instead of using a fork, we subclass the filter and only apply the
`task-list` class to list items that actually are task lists.

Closes #1645

See https://github.com/github/task_list/pull/60
2015-05-20 12:08:33 -04:00
Dmitriy Zaporozhets 9c6f4a2351 Merge branch 'dashboard-references' into 'master'
Fix reference links in dashboard activity and ATOM feeds.

References like `@user` were not linked on the dashboard activity feed and in Atom feeds, because the reference parser depends on `@project` which isn't set in those situations.

This MR passes the project in question to the reference parsers in an option.

cc @rspeicher

See merge request !653
2015-05-15 09:59:26 +00:00
Douwe Maan cd52cef1c0 Fix reference links in dashboard activity and ATOM feeds. 2015-05-14 13:05:33 +02:00
Robert Speicher 7f2fb72a0a Minor RelativeLinkFilter cleanup 2015-05-13 14:08:37 -04:00
Jakub Jirutka b3276661f7 RelativeLinkFilter: refactor according to suggestions by @tsigo 2015-05-11 20:43:18 +02:00
Jakub Jirutka f7adac87fe Extract handling of relative file links to RelativeLinkFilter 2015-05-11 02:07:26 +02:00
Robert Speicher 6883e6e084 Remove all references to parse_tasks 2015-05-06 12:58:28 -04:00
Robert Speicher 61c73575c3 Add TaskList::Filter to pipeline 2015-05-06 12:58:27 -04:00
Robert Speicher 588267b5e2 Update the Gitlab::Markdown docs 2015-04-30 16:35:26 -04:00
Robert Speicher e46d1cdd8b Add Gitlab::Markdown::SanitizationFilter
This just extends the HTML::Pipeline::SanitizationFilter with our custom
whitelist.
2015-04-30 16:35:25 -04:00
Robert Speicher aa2cc670fe Add Gitlab::Markdown::AutolinkFilter 2015-04-30 16:35:25 -04:00
Robert Speicher 382a0aa6ef Add Gitlab::Markdown::TableOfContentsFilter
Removes header and table of contents processing from Redcarpet renderer.
2015-04-30 16:35:25 -04:00
Robert Speicher a14d109b9b Provide autoload paths for filters to prevent circular dependency 2015-04-23 12:58:55 -04:00
Robert Speicher fca624670a Update Gitlab::Markdown to use the 🆕 EmojiFilter
Removes emoji-centric tests from GFM specs 💥
2015-04-21 12:53:42 -04:00
Robert Speicher 34a23bda60 Add current_user to filter context 2015-04-20 13:01:43 -04:00
Robert Speicher 77a6746a75 Run SanitizationFilter before our reference filters 2015-04-20 13:01:42 -04:00
Robert Speicher 96c2b94048 Reference filters
Commit ranges, commits, external issues, issues, labels, merge requests,
snippets, users.
2015-04-20 13:01:42 -04:00
Dmitriy Zaporozhets bd97715a57 Merge branch 'fix-label-color' into 'master'
Parse GFM references after sanitizing

Parse GFM references - labels, issues, MRs, etc. - after calling the HTML Pipeline `SanitizationFilter` so that we can use non-whitelisted attributes like `style`.  See #2188.

See merge request !1745
2015-04-20 08:40:13 +00:00
Vinnie Okada df9a992c15 Fix GFM extractions
Extract and re-insert links after sanitizing user markup.
2015-04-17 20:39:38 -06:00
Dmitriy Zaporozhets ecb58dacd6 Merge branch 'reference-access-control' into 'master'
Only allow users to reference groups, projects, issues, MRs, commits they have access to.

Addresses https://dev.gitlab.org/gitlab/gitlabhq/issues/2183.

See merge request !1742
2015-04-13 14:10:25 +00:00
Douwe Maan 9d647197da Don't require user to every gfm call. 2015-04-03 18:03:01 +02:00
Douwe Maan c5d7660000 Fix errors. 2015-04-02 22:36:54 +02:00
Dmitriy Zaporozhets f8f9750323 Merge branch 'username-period' into 'master'
Don't allow username to end in period.

The current behavior doesn't do username referencing and mentioning in sentences like "I discussed with with @douwe." since `douwe.` is matched as a username.

Addresses private issue https://dev.gitlab.org/gitlab/gitlabhq/issues/2174.

See merge request !438
2015-04-02 20:28:23 +00:00
Douwe Maan ca58e369c9 Only allow user to reference objects they have access to. 2015-04-02 10:56:04 +02:00
Marin Jankovski d77f333f9c Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce
Conflicts:
	lib/gitlab/markdown.rb
2015-03-31 19:03:54 -07:00
Dmitriy Zaporozhets dc3b4321ff Merge branch 'group-information-leak' into 'master'
Don't leak private group existence by redirecting from namespace controller to group controller.

See merge request !440
2015-04-01 01:01:38 +00:00
Vinnie Okada 9deda68257 Parse GFM references after sanitizing
Parse GFM references - labels, issues, MRs, etc. - after calling the
HTML Pipeline `SanitizationFilter` so that we can use non-whitelisted
attributes like `style`.
2015-03-28 08:58:30 -06:00
Douwe Maan 5f93b0e3da Don't allow username to end in period. 2015-03-27 11:10:56 +01:00
Douwe Maan e08d947e77 Use relative URL for Markdown references, except in mails. 2015-03-27 10:39:05 +01:00
Vinnie Okada 057c8c344b Merge branch 'master' into markdown-tags 2015-03-24 20:03:22 -06:00
Douwe Maan 61e8ca8ce0 Don't leak private group existence by redirecting from namespace controller to group controller. 2015-03-24 15:55:12 +01:00
Vinnie Okada a7afc06342 Fix SanitizationFilter bugs
Return a `SafeBuffer` instead of a `String` from the `#gfm_with_options`
method so that Rails doesn't escape our markup.

Also add `<span>` to the sanitization whitelist to avoid breaking syntax
highlighting in code blocks.
2015-03-22 20:17:56 -06:00
Vinnie Okada 1dc90fc455 Fix nested task lists
When nesting task list items, the parent item is wrapped in a `<p>` tag.
Update the task list parser to handle these paragraph wrappers.
2015-03-21 08:45:28 -06:00
Vinnie Okada cc29ce4917 Don't allow style attributes in inline HTML 2015-03-21 08:39:54 -06:00
Vinnie Okada 52bf95ae38 Change HTML sanitization
Use the `SanitizationFilter` class from the html-pipeline gem for inline
HTML instead of calling the Rails `sanitize` method.
2015-03-19 21:24:07 -06:00
Vinnie Okada feeffc4426 Merge branch 'master' into markdown-tags
Use the latest HTML pipeline gem
2015-03-17 20:53:09 -06:00
Douwe Maan e4ac6bbf82 Merge branch 'atom-xhtml-squashed' into 'master'
Fix invalid Atom feeds when using emoji, horizontal rules, or images

This is a fix for issues #880, #723, #1113.

Markdown must be rendered to XHTML, not HTML, when generating summary content for Atom feeds. Otherwise, content-less tags like *img* and *hr* are not terminated and make the Atom XML invalid. Such tags are generated when issue descriptions, merge request descriptions, comments, or commit messages use emoji, horizontal rules, or images.

To pass this option through from the relevant Haml templates to the proper place in the `gfm()` method, a new method `gfm_with_options()` is introduced. It reuses the options dictionary passed to `markdown()` and interprets options `xhtml` and `parse_tasks` from it (the latter was a convenient replacement for `gfm_with_tasks()`). `xhtml` is already interpreted by Redcarpet::Render::HTML, but that alone was not sufficient, because the post-processing in `gfm()` would convert its XHTML tags back to HTML.

I found no way of passing additional optional options to the existing `gfm()` method without requiring updates to existing callers and without getting in the way of the existing optional arguments, but maybe someone who knows more about Ruby than I can think of one.

Thorough review appreciated since this is the first time I have used Ruby.

See merge request !344
2015-03-17 08:38:38 +00:00
Christian Walther 90aa870c36 Fix invalid Atom feeds when using emoji, horizontal rules, or images.
Fixes issues #880, #723, #1113: Markdown must be rendered to XHTML, not HTML, when generating summary content for Atom feeds. Otherwise, content-less tags like <img> and <hr>, generated when issue descriptions, merge request descriptions, comments, or commit messages use emoji, horizontal rules, or images, are not terminated and make the Atom XML invalid.
2015-03-16 22:05:52 +01:00
Douwe Maan 31fc73f0a9 Use project_member instead of team_member. 2015-03-15 13:50:38 +01:00
Douwe Maan 4dddaef866 Automatically link commit ranges to compare page. 2015-03-07 00:46:13 +01:00
Nicolas Bouilleaud 8d0690c5c7 Support names starting with a digit or _ for projects and users
This is what’s actually allowed when creating a user or a project in gitlab.
2015-03-02 11:01:17 +01:00
Vinnie Okada 76aad9b76e Upgrade to Rails 4.1.9
Make the following changes to deal with new behavior in Rails 4.1.2:

* Use nested resources to avoid slashes in arguments to path helpers.
2015-02-14 11:09:23 -07:00