gitlab-markup 1.6.4 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +104 -12
- data/HISTORY.md +17 -0
- data/README.md +7 -5
- data/bin/{github-markup → gitlab-markup} +0 -0
- data/gitlab-markup.gemspec +3 -2
- data/lib/github/commands/rest2html +2 -1
- data/lib/github/markup/command_implementation.rb +31 -11
- data/lib/github/markups.rb +1 -1
- data/lib/github-markup.rb +1 -1
- data/test/markups/README.large.rst +1322 -0
- data/test/markups/README.large.rst.html +1228 -0
- data/test/markups/README.rst.html +37 -0
- metadata +16 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffe78f2c70532bd5111c1adba163151a60108ceec4525f022a47032af7579192
|
4
|
+
data.tar.gz: c0d89038ace9d3756e7866d711776e830469d03a70e7d7a25edf93e964f285c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba9c3cf53d15ac267552fb7013dc1612b8ae4e15a71aeed4b256f38bd2bcbe6152fb089b9d82c49598ef0556a5f16f7ae72c288adfd95c8d69f40a2929ea268d
|
7
|
+
data.tar.gz: 8db081c15c4883e1d51285575bbfcdd9fb9074767d019988a35cead5de3ffaee1f79fd1fea1ef616f265dee25b12080c5f0b652079165b1fa1c0201c9497eb47
|
data/.gitlab-ci.yml
CHANGED
@@ -1,24 +1,116 @@
|
|
1
|
+
include:
|
2
|
+
- template: SAST.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/blob/master/lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml
|
3
|
+
- template: Security/Dependency-Scanning.gitlab-ci.yml # https://docs.gitlab.com/ee/user/application_security/dependency_scanning/
|
4
|
+
- template: Security/Secret-Detection.gitlab-ci.yml # https://docs.gitlab.com/ee/user/application_security/secret_detection/
|
5
|
+
|
1
6
|
variables:
|
2
7
|
LANG: "C.UTF-8"
|
3
8
|
|
4
|
-
|
9
|
+
default:
|
10
|
+
tags:
|
11
|
+
- gitlab-org
|
12
|
+
|
13
|
+
workflow:
|
14
|
+
rules: &workflow_rules
|
15
|
+
# For merge requests, create a pipeline.
|
16
|
+
- if: '$CI_MERGE_REQUEST_IID'
|
17
|
+
# For `master` branch, create a pipeline (this includes on schedules, pushes, merges, etc.).
|
18
|
+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
19
|
+
# For tags, create a pipeline.
|
20
|
+
- if: '$CI_COMMIT_TAG'
|
21
|
+
|
22
|
+
.specs:
|
5
23
|
cache:
|
24
|
+
key: "$CI_JOB_NAME"
|
6
25
|
paths:
|
7
26
|
- vendor/ruby
|
8
27
|
before_script:
|
9
28
|
- apt update
|
10
|
-
- apt install
|
11
|
-
-
|
29
|
+
- apt install python3 python3-pip git build-essential -y
|
30
|
+
- apt remove python -y
|
31
|
+
- pip3 install "docutils==$DOCUTILS_VERSION"
|
12
32
|
- bundle install --jobs $(nproc)
|
13
33
|
script:
|
34
|
+
- echo "Testing without posix-spawn..."
|
35
|
+
- cp Gemfile Gemfile.orig
|
36
|
+
- sed -i -e '/posix-spawn/d' Gemfile
|
37
|
+
- bundle install
|
14
38
|
- bundle exec rake test
|
39
|
+
- echo "Testing with posix-spawn..."
|
40
|
+
- mv Gemfile.orig Gemfile
|
41
|
+
- bundle install
|
42
|
+
- bundle exec rake test
|
43
|
+
|
44
|
+
.docutils-014:
|
45
|
+
variables:
|
46
|
+
DOCUTILS_VERSION: "0.14"
|
47
|
+
|
48
|
+
.docutils-015:
|
49
|
+
variables:
|
50
|
+
DOCUTILS_VERSION: "0.15.2"
|
51
|
+
|
52
|
+
.docutils-016:
|
53
|
+
variables:
|
54
|
+
DOCUTILS_VERSION: "0.16"
|
55
|
+
|
56
|
+
ruby-25:
|
57
|
+
image: ruby:2.5
|
58
|
+
extends:
|
59
|
+
- .docutils-014
|
60
|
+
- .specs
|
61
|
+
|
62
|
+
ruby-26:
|
63
|
+
image: ruby:2.6
|
64
|
+
extends:
|
65
|
+
- .docutils-014
|
66
|
+
- .specs
|
67
|
+
|
68
|
+
ruby-27:
|
69
|
+
image: ruby:2.7
|
70
|
+
extends:
|
71
|
+
- .docutils-014
|
72
|
+
- .specs
|
73
|
+
|
74
|
+
ruby-25-du15:
|
75
|
+
image: ruby:2.5
|
76
|
+
extends:
|
77
|
+
- .docutils-015
|
78
|
+
- .specs
|
79
|
+
|
80
|
+
ruby-26-du15:
|
81
|
+
image: ruby:2.6
|
82
|
+
extends:
|
83
|
+
- .docutils-015
|
84
|
+
- .specs
|
85
|
+
|
86
|
+
ruby-27-du15:
|
87
|
+
image: ruby:2.7
|
88
|
+
extends:
|
89
|
+
- .docutils-015
|
90
|
+
- .specs
|
91
|
+
|
92
|
+
ruby-25-du16:
|
93
|
+
image: ruby:2.5
|
94
|
+
extends:
|
95
|
+
- .docutils-016
|
96
|
+
- .specs
|
97
|
+
|
98
|
+
ruby-26-du16:
|
99
|
+
image: ruby:2.6
|
100
|
+
extends:
|
101
|
+
- .docutils-016
|
102
|
+
- .specs
|
103
|
+
|
104
|
+
ruby-27-du16:
|
105
|
+
image: ruby:2.7
|
106
|
+
extends:
|
107
|
+
- .docutils-016
|
108
|
+
- .specs
|
109
|
+
|
110
|
+
# Dependency Scanning
|
111
|
+
gemnasium-dependency_scanning:
|
112
|
+
rules: *workflow_rules
|
15
113
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
ruby-22:
|
20
|
-
image: ruby:2.2
|
21
|
-
<<: *specs
|
22
|
-
ruby-23:
|
23
|
-
image: ruby:2.3
|
24
|
-
<<: *specs
|
114
|
+
# Secret Detection
|
115
|
+
secret_detection:
|
116
|
+
rules: *workflow_rules
|
data/HISTORY.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
## 1.8.0 (2021-12-02)
|
2
|
+
|
3
|
+
* Disable configuration file processing in RST
|
4
|
+
* Wrap call to rest2html in a timeout
|
5
|
+
|
6
|
+
## 1.7.1 (2020-05-01)
|
7
|
+
|
8
|
+
* Fix RST rendering not working for large files
|
9
|
+
|
10
|
+
## 1.7.0 (2019-03-05)
|
11
|
+
|
12
|
+
* Require Python 3
|
13
|
+
|
14
|
+
## 1.6.5 (2018-10-31)
|
15
|
+
|
16
|
+
* Renamed executable from `github-markup` to `gitlab-markup`
|
17
|
+
|
1
18
|
## 1.6.4 (2018-06-08)
|
2
19
|
|
3
20
|
* Fixed extra blank line at start of rendered reStructuredText code block
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
GitLab Markup
|
2
2
|
=============
|
3
3
|
|
4
|
-
[![build status](https://gitlab.com/gitlab-org/gitlab-markup/badges/master/
|
4
|
+
[![build status](https://gitlab.com/gitlab-org/gitlab-markup/badges/master/pipeline.svg)](https://gitlab.com/gitlab-org/gitlab-markup/commits/master)
|
5
5
|
|
6
6
|
This library is a fork of GitHub Markup, which is used to render all non Markdown markups:
|
7
7
|
|
@@ -17,15 +17,15 @@ Markups
|
|
17
17
|
-------
|
18
18
|
|
19
19
|
The following markups are supported. The dependencies listed are required if
|
20
|
-
you wish to run the library. You can also run `script/bootstrap` to fetch them all.
|
20
|
+
you wish to run the library. You can also run `script/bootstrap` to fetch them all (Python 3 required).
|
21
21
|
|
22
22
|
* [.markdown, .mdown, .mkdn, .md](http://daringfireball.net/projects/markdown/) -- `gem install redcarpet` (https://github.com/vmg/redcarpet)
|
23
23
|
* [.textile](http://www.textism.com/tools/textile/) -- `gem install RedCloth`
|
24
|
-
* [.rdoc](
|
24
|
+
* [.rdoc](https://ruby.github.io/rdoc/) -- `gem install rdoc -v 3.6.1`
|
25
25
|
* [.org](http://orgmode.org/) -- `gem install org-ruby`
|
26
26
|
* [.creole](http://wikicreole.org/) -- `gem install creole`
|
27
27
|
* [.mediawiki, .wiki](http://www.mediawiki.org/wiki/Help:Formatting) -- `gem install wikicloth`
|
28
|
-
* [.rst](
|
28
|
+
* [.rst](https://docutils.sourceforge.io/rst.html) -- `pip install docutils`
|
29
29
|
* [.asciidoc, .adoc, .asc](http://asciidoc.org/) -- `gem install asciidoctor` (http://asciidoctor.org)
|
30
30
|
* [.pod](http://search.cpan.org/dist/perl/pod/perlpod.pod) -- `Pod::Simple::HTML`
|
31
31
|
comes with Perl >= 5.10. Lower versions should install [Pod::Simple](http://search.cpan.org/~dwheeler/Pod-Simple-3.28/lib/Pod/Simple.pod) from CPAN.
|
@@ -33,7 +33,9 @@ you wish to run the library. You can also run `script/bootstrap` to fetch them a
|
|
33
33
|
Installation
|
34
34
|
-----------
|
35
35
|
|
36
|
-
|
36
|
+
Ruby 2.6+ is highly recommended (Ruby 2.5 is still supported).
|
37
|
+
|
38
|
+
```shell
|
37
39
|
gem install gitlab-markup
|
38
40
|
```
|
39
41
|
|
File without changes
|
data/gitlab-markup.gemspec
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require File.expand_path('../lib/github-markup', __FILE__)
|
2
3
|
|
3
4
|
Gem::Specification.new do |s|
|
@@ -24,7 +25,7 @@ Gem::Specification.new do |s|
|
|
24
25
|
s.add_development_dependency 'activesupport', '~> 4.0'
|
25
26
|
s.add_development_dependency 'html-pipeline', '~> 1.0'
|
26
27
|
s.add_development_dependency 'minitest', '~> 5.4.3'
|
27
|
-
s.add_development_dependency 'nokogiri', '~> 1.
|
28
|
+
s.add_development_dependency 'nokogiri', '~> 1.10.9'
|
28
29
|
s.add_development_dependency 'nokogiri-diff', '~> 0.2.0'
|
29
|
-
s.add_development_dependency 'sanitize', '~>
|
30
|
+
s.add_development_dependency 'sanitize', '~> 5.1.0'
|
30
31
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/usr/bin/env
|
1
|
+
#!/usr/bin/env python3
|
2
2
|
"""
|
3
3
|
rest2html - A small wrapper file for parsing ReST files at GitHub.
|
4
4
|
|
@@ -54,6 +54,7 @@ from docutils.core import publish_parts
|
|
54
54
|
from docutils.writers.html4css1 import Writer, HTMLTranslator
|
55
55
|
|
56
56
|
SETTINGS = {
|
57
|
+
'_disable_config': True,
|
57
58
|
'cloak_email_addresses': False,
|
58
59
|
'file_insertion_enabled': False,
|
59
60
|
'raw_enabled': False,
|
@@ -12,6 +12,8 @@ module GitHub
|
|
12
12
|
end
|
13
13
|
|
14
14
|
class CommandImplementation < Implementation
|
15
|
+
DEFAULT_GITLAB_MARKUP_TIMEOUT = '10'.freeze
|
16
|
+
|
15
17
|
attr_reader :command, :block, :name
|
16
18
|
|
17
19
|
def initialize(regexp, command, name, &block)
|
@@ -27,7 +29,8 @@ module GitHub
|
|
27
29
|
call_block(rendered, content)
|
28
30
|
end
|
29
31
|
|
30
|
-
|
32
|
+
private
|
33
|
+
|
31
34
|
def call_block(rendered, content)
|
32
35
|
if block && block.arity == 2
|
33
36
|
block.call(rendered, content)
|
@@ -38,27 +41,44 @@ module GitHub
|
|
38
41
|
end
|
39
42
|
end
|
40
43
|
|
44
|
+
def timeout_in_seconds
|
45
|
+
ENV.fetch('GITLAB_MARKUP_TIMEOUT', DEFAULT_GITLAB_MARKUP_TIMEOUT).to_i
|
46
|
+
end
|
47
|
+
|
48
|
+
def prepend_command_timeout_prefix(command)
|
49
|
+
timeout_command_prefix = "timeout --signal=KILL #{timeout_in_seconds}"
|
50
|
+
|
51
|
+
# Preserve existing support for command being either a String or an Array
|
52
|
+
if command.is_a?(String)
|
53
|
+
"#{timeout_command_prefix} #{command}"
|
54
|
+
else
|
55
|
+
timeout_command_prefix.split(' ') + command
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
41
59
|
if defined?(POSIX::Spawn)
|
42
60
|
def execute(command, target)
|
43
|
-
|
61
|
+
command_with_timeout_prefix = prepend_command_timeout_prefix(command)
|
62
|
+
spawn = POSIX::Spawn::Child.new(*command_with_timeout_prefix, :input => target)
|
44
63
|
if spawn.status.success?
|
45
64
|
sanitize(spawn.out, target.encoding)
|
65
|
+
elsif spawn.status.termsig == Signal.list['KILL']
|
66
|
+
raise TimeoutError.new("Command was killed, probably due to exceeding GITLAB_MARKUP_TIMEOUT limit of #{timeout_in_seconds} seconds")
|
46
67
|
else
|
47
68
|
raise CommandError.new(spawn.err.strip)
|
48
69
|
end
|
49
70
|
end
|
50
71
|
else
|
51
72
|
def execute(command, target)
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
73
|
+
command_with_timeout_prefix = prepend_command_timeout_prefix(command)
|
74
|
+
stdout_str, stderr_str, status = Open3.capture3(*command_with_timeout_prefix, stdin_data: target)
|
75
|
+
if status.success?
|
76
|
+
sanitize(stdout_str, target.encoding)
|
77
|
+
elsif status.termsig == Signal.list['KILL']
|
78
|
+
raise TimeoutError.new("Command was killed, probably due to exceeding GITLAB_MARKUP_TIMEOUT limit of #{timeout_in_seconds} seconds")
|
79
|
+
else
|
80
|
+
raise CommandError.new(stderr_str.strip)
|
60
81
|
end
|
61
|
-
sanitize(output.join(''), target.encoding)
|
62
82
|
end
|
63
83
|
end
|
64
84
|
|
data/lib/github/markups.rb
CHANGED
@@ -33,7 +33,7 @@ markup(:asciidoctor, /adoc|asc(iidoc)?/) do |content|
|
|
33
33
|
end
|
34
34
|
|
35
35
|
command(
|
36
|
-
"
|
36
|
+
"python3 #{Shellwords.escape(File.dirname(__FILE__))}/commands/rest2html",
|
37
37
|
/re?st(\.txt)?/,
|
38
38
|
"restructuredtext"
|
39
39
|
)
|