dependabot-common 0.113.8 → 0.113.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e237dcfe1f60fe9dc9e264f5119d916c6498bf11180ab832067f8f50e40053c4
4
- data.tar.gz: 739ba909c900ebc9635ff04f312237e6c3e3f9a66e651da9194c66df83bda86e
3
+ metadata.gz: 60e3f6c2910095cf1e21ab00b6d1336c09c21cc90b570726e78c9960247c3967
4
+ data.tar.gz: 455b12c4441a1f7fb9c02cbbb2f09c97ed6062f469a65fef0f3f14cd22c5896f
5
5
  SHA512:
6
- metadata.gz: a2e013639daedfa94637e55ad67e54c6e1be464ea6e2bc4074831cc939e311ed71c8b8aa86502770f0762d311b2fdefb9618b5a59ab57e2e0113a7a6d0a5296d
7
- data.tar.gz: 51ba82962b4df0eeb9700c80763d791315ceb4f09fcaed69cc5d4d7921a6564ffef716fd2dc01fc69d177c15bd956516f766d1f6ee77a22d802323dc1b8a4859
6
+ metadata.gz: cdd202276dd4fd64fde6eefb90cba469cd6664b3fc08980034aff0ee0c6c9e0b9d979ef0e8df321034a818c768b94a03c8dde71762919f062f2a3df2a71d6692
7
+ data.tar.gz: 8948467061cc76c797e9ca2697d26cb143766eee9f54aed8a0e5adefa7e61296148943987ddcbf9f9d01f6d9436aa8392bce189ea52481827fa19ad15fc503c2
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "strscan"
3
4
  require "dependabot/pull_request_creator/message_builder"
4
5
 
5
6
  module Dependabot
@@ -12,18 +13,9 @@ module Dependabot
12
13
  github\.com/(?<repo>#{GITHUB_USERNAME}/[^/\s]+)/
13
14
  (?:issue|pull)s?/(?<number>\d+)
14
15
  }x.freeze
15
-
16
- # Note that we're being deliberately careful about not matching
17
- # different length strings of what look like code block quotes. By
18
- # doing so we err on the side of sanitizing, which is *much* better
19
- # than accidentally not sanitizing.
20
- #
21
- # rubocop:disable Style/RegexpLiteral
22
- CODEBLOCK_REGEX = %r{
23
- (?=[\s]`{3}[^`])|(?=[\s]`{3}\Z)|(?=\A`{3}[^`])|
24
- (?=[\s]~{3}[^~])|(?=[\s]~{3}\Z)|(?=\A~{3}[^~])
25
- }x.freeze
26
- # rubocop:enable Style/RegexpLiteral
16
+ CODEBLOCK_REGEX = /```|~~~/.freeze
17
+ # End of string
18
+ EOS_REGEX = /\z/.freeze
27
19
 
28
20
  attr_reader :github_redirection_service
29
21
 
@@ -33,18 +25,20 @@ module Dependabot
33
25
 
34
26
  def sanitize_links_and_mentions(text:)
35
27
  # We don't want to sanitize any links or mentions that are contained
36
- # within code blocks, so we split the text on "```"
37
- snippets = text.split(CODEBLOCK_REGEX)
38
- if snippets.first&.start_with?(CODEBLOCK_REGEX)
39
- snippets = ["", *snippets]
28
+ # within code blocks, so we split the text on "```" or "~~~"
29
+ lines = []
30
+ scan = StringScanner.new(text)
31
+ until scan.eos?
32
+ line = scan.scan_until(CODEBLOCK_REGEX) ||
33
+ scan.scan_until(EOS_REGEX)
34
+ delimiter = line.match(CODEBLOCK_REGEX)&.to_s
35
+ unless delimiter && lines.count { |l| l.include?(delimiter) }.odd?
36
+ line = sanitize_mentions(line)
37
+ line = sanitize_links(line)
38
+ end
39
+ lines << line
40
40
  end
41
-
42
- snippets.map.with_index do |snippet, index|
43
- next snippet if index.odd?
44
-
45
- snippet = sanitize_mentions(snippet)
46
- sanitize_links(snippet)
47
- end.join
41
+ lines.join
48
42
  end
49
43
 
50
44
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dependabot
4
- VERSION = "0.113.8"
4
+ VERSION = "0.113.9"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.113.8
4
+ version: 0.113.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-02 00:00:00.000000000 Z
11
+ date: 2019-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-codecommit