Commit Graph

13 Commits

Author SHA1 Message Date
GitLab Bot ec8587780b Add latest changes from gitlab-org/gitlab@master 2021-06-23 00:07:53 +00:00
GitLab Bot f7bc7dc5ea Add latest changes from gitlab-org/gitlab@master 2021-06-01 21:10:06 +00:00
GitLab Bot 100a5e4bea Add latest changes from gitlab-org/gitlab@master 2020-05-25 21:08:00 +00:00
GitLab Bot 0a850868df Add latest changes from gitlab-org/gitlab@master 2019-10-09 12:06:13 +00:00
Kerri Miller acc694ead6 Extract SanitizeNodeLink and apply to WikiLinkFilter
The SanitizationFilter was running before the WikiFilter. Since
WikiFilter can modify links, we could see links that _should_ be stopped
by SanatizationFilter being rendered on the page. I (kerrizor) had
previously addressed the bug in: 7bc971915b
However, an additional exploit was discovered after that was merged.
Working through the issue, we couldn't simply shuffle the order of
filters, due to some implicit assumptions about the order of filters, so
instead we've extracted the logic that sanitizes a Nokogiri-generated
Node object, and applied it to the WikiLinkFilter as well.

On moving filters around:
Once we start moving around filters, we get cascading failures; fix one,
another one crops up. Many of the existing filters in the WikiPipeline
chain seem to assume that other filters have already done their work,
and thus operate on a "transform anything that's left" basis;
WikiFilter, for instance, assumes any link it finds in the markdown
should be prepended with the wiki_base_path.. but if it does that, it
also turns `href="@user"` into `href="/path/to/wiki/@user"`, which the
UserReferenceFilter doesn't see as a user reference it needs to
transform into a user profile link. This is true for all the reference
filters in the WikiPipeline.
2019-07-26 13:41:11 +00:00
Francisco Javier López f9475e299c Uploads to wiki stored inside the wiki git repository 2018-09-04 10:39:08 +00:00
Stan Hu 8b4154b57f Enable frozen strings in lib/banzai/filter/*.rb
Excludes a few filters that require more work:

* lib/banzai/filter/image_lazy_load_filter_spec.rb
* lib/banzai/filter/syntax_highlight_filter_spec.rb
* lib/banzai/filter/table_of_contents_filter_spec.rb

Part of #47424
2018-07-23 02:39:45 -07:00
Grzegorz Bizon 9e211091a8 Enable Style/EmptyLines cop, remove redundant ones 2016-07-01 21:56:17 +02:00
Timothy Andrew 6d169d36ca Fix bug in `WikiLinkFilter`.
1. An exception would be raised if the filter was called with an invalid
   URI. Mainly because we weren't catching the `Addressable` exception.

2. This commit fixes it and adds a spec for the filter.
2016-06-18 14:10:40 +05:30
Timothy Andrew 8e71c19a69 Implement the correct linking behaviour in `WikiLinkFilter`.
Original Comments
=================

- Linking behaves as per rules documented here:
  https://gitlab.com/gitlab-org/gitlab-ce/blob/16568-document-wiki-linking-behavior/doc/markdown/wiki.md
- All links (to other wiki pages) are rewritten to be at the level of
  the app root. We can't use links relative to the current
  page ('./foo', 'foo', '../foo'), because they won't work in the
  markdown preview, where the current page is suffixed with `/edit`
- Move existing `WikiLinkFilter` specs to `WikiPipeline` spec. It makes
  sense to run these tests on the combined output of the pipeline,
  rather than a single filter, since we can catch issues with
  conflicting filters.
- Add more tests to cover the new linking

@rymai's Review
===============

- Classes nested under `WikiLinkFilter` should declare `WikiLinkFilter`'s
  inherit, so nothing changes if the nested class is loaded first.
- Add a blank line after a guard clause
- Use keyword arguments for the `Rewriter` constructor
- Invert a condition - use `if` instead of `unless`
- Inline a `let` in `WikiPipeline` spec - it was only used in a single place
- Change out of date spec names
- Add a comment for every rewrite rule in `Rewriter`
2016-06-09 10:04:15 +05:30
Timothy Andrew a59ad3936a Add a spec for `WikiLinkFilter`
- And fix behavior for non-file hierarchical links.
2016-05-12 07:17:07 +05:30
Gabriel Mazetto 22055e1058 Fix a few edited references from WikiLinkFilter and specs 2016-04-06 03:13:46 -03:00
Gabriel Mazetto 28266d9d61 Added WikiLinkFilter 2016-04-01 00:17:37 -03:00