dependabot-common 0.113.11 → 0.113.12

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: 48912fb9054dc3409b1b3890324d5664883666841e73899c81f82fada8709598
4
- data.tar.gz: 721c424e9b83f4fcac58772d09df61f8539df3594ba65094d04e3b4a9f2e4976
3
+ metadata.gz: 3e11294f909352aa0f8826372c144b15e8f5ba4d38ac114e784c4537ac4c4c44
4
+ data.tar.gz: 2ff645789e8130aa5c188d80c6a2656900513e2d1cfdd0176b2fa61726e821f4
5
5
  SHA512:
6
- metadata.gz: 5f604c14e2298705ca0714bd7a9c4097d9cfcebfff9200fcee4476f997897175339134a921f497b0d79730bab55a85246ffa51e02f2ffa988556bdaaa26418b2
7
- data.tar.gz: ecc17f5c9ae5f4cea9e937c82468831d44c18d86bc90c4aef02ed846a27832dd636968ca9b79f32c2102fd1590b9d66db899993398ced48c07577d983dba0340
6
+ metadata.gz: 2ab237d88e37547717b86992b029dce437bc0eaab0239133c61f63de20849c5aaecb803043361bbd74e41a8ac3d91017508faf95443057c9e40a618ce45ce052
7
+ data.tar.gz: bfaae794e512efb73b58f2c5f187d3f67727d89ab0778e6794ea3f3deeeeba8036a654c12c7d271fc900838ab2aa2dd8d0d9a4f981f8af78512a0c326cac76e0
@@ -13,7 +13,7 @@ module Dependabot
13
13
  github\.com/(?<repo>#{GITHUB_USERNAME}/[^/\s]+)/
14
14
  (?:issue|pull)s?/(?<number>\d+)
15
15
  }x.freeze
16
- CODEBLOCK_REGEX = /```|~~~/.freeze
16
+ CODEBLOCK_REGEX = /(`+).*?(\1)|~~~.*?~~~/m.freeze
17
17
  # End of string
18
18
  EOS_REGEX = /\z/.freeze
19
19
 
@@ -26,23 +26,34 @@ module Dependabot
26
26
  def sanitize_links_and_mentions(text:)
27
27
  # We don't want to sanitize any links or mentions that are contained
28
28
  # within code blocks, so we split the text on "```" or "~~~"
29
- lines = []
29
+ sanitized_text = []
30
30
  scan = StringScanner.new(text)
31
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
32
+ block = scan.scan_until(CODEBLOCK_REGEX) ||
33
+ scan.scan_until(EOS_REGEX)
34
+ sanitized_text << sanitize_links_and_mentions_in_block(block)
40
35
  end
41
- lines.join
36
+ sanitized_text.join
42
37
  end
43
38
 
44
39
  private
45
40
 
41
+ def sanitize_links_and_mentions_in_block(block)
42
+ # Handle code blocks one by one
43
+ normal_text = block
44
+ verbatim_text = ""
45
+ match = block.match(CODEBLOCK_REGEX)
46
+ if match
47
+ # Part leading up to start of code block
48
+ normal_text = match.pre_match
49
+ # Entire code block copied verbatim
50
+ verbatim_text = match.to_s
51
+ end
52
+ normal_text = sanitize_mentions(normal_text)
53
+ normal_text = sanitize_links(normal_text)
54
+ normal_text + verbatim_text
55
+ end
56
+
46
57
  def sanitize_mentions(text)
47
58
  text.gsub(%r{(?<![A-Za-z0-9`~])@#{GITHUB_USERNAME}/?}) do |mention|
48
59
  next mention if mention.end_with?("/")
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dependabot
4
- VERSION = "0.113.11"
4
+ VERSION = "0.113.12"
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.11
4
+ version: 0.113.12
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-08 00:00:00.000000000 Z
11
+ date: 2019-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-codecommit