dependabot-common 0.113.6 → 0.113.11

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: 357d4ec95f23bfd1ba9bd76cd00a043b187d7094a73ad567f1d0b471110451cf
4
- data.tar.gz: 52aad85593c1ce95951ac42e6cc9d3c098859ba18a5197fec2df611cc726bf2f
3
+ metadata.gz: 48912fb9054dc3409b1b3890324d5664883666841e73899c81f82fada8709598
4
+ data.tar.gz: 721c424e9b83f4fcac58772d09df61f8539df3594ba65094d04e3b4a9f2e4976
5
5
  SHA512:
6
- metadata.gz: 383d7211d4938c43bf3edcd9a8f0782494ad4cca8a28d276dd5017c41b7ff1188393f5c032d9b259ddb891d3d4c9afd01b8cf556f7e1b5abf412d13451a19e83
7
- data.tar.gz: 5d1bedccf30f94c65d44fd818f0911616b2142b68b064cfbb6302879199039353948ae6e77b6129bc0ed0e14324b52d49444b0696a580e92845a90326a290f19
6
+ metadata.gz: 5f604c14e2298705ca0714bd7a9c4097d9cfcebfff9200fcee4476f997897175339134a921f497b0d79730bab55a85246ffa51e02f2ffa988556bdaaa26418b2
7
+ data.tar.gz: ecc17f5c9ae5f4cea9e937c82468831d44c18d86bc90c4aef02ed846a27832dd636968ca9b79f32c2102fd1590b9d66db899993398ced48c07577d983dba0340
@@ -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.6"
4
+ VERSION = "0.113.11"
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.6
4
+ version: 0.113.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-30 00:00:00.000000000 Z
11
+ date: 2019-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-codecommit
@@ -286,14 +286,14 @@ dependencies:
286
286
  requirements:
287
287
  - - "~>"
288
288
  - !ruby/object:Gem::Version
289
- version: 0.74.0
289
+ version: 0.75.0
290
290
  type: :development
291
291
  prerelease: false
292
292
  version_requirements: !ruby/object:Gem::Requirement
293
293
  requirements:
294
294
  - - "~>"
295
295
  - !ruby/object:Gem::Version
296
- version: 0.74.0
296
+ version: 0.75.0
297
297
  - !ruby/object:Gem::Dependency
298
298
  name: vcr
299
299
  requirement: !ruby/object:Gem::Requirement