This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 4c163af  Allow for possible meta-chars
4c163af is described below

commit 4c163af1d65736e3cdb173f90f7dea1fc0dea02f
Author: Sebb <[email protected]>
AuthorDate: Thu Feb 18 17:04:32 2021 +0000

    Allow for possible meta-chars
---
 lib/whimsy/asf/committee.rb                           | 4 ++--
 lib/whimsy/asf/yaml.rb                                | 2 +-
 www/board/agenda/models/minutes.rb                    | 2 +-
 www/board/agenda/views/actions/attend.json.rb         | 6 +++---
 www/board/agenda/views/actions/posted-reports.json.rb | 4 ++--
 www/board/posted-reports.cgi                          | 6 +++---
 www/members/nominations.cgi                           | 4 ++--
 www/roster/views/actions/ppmc.json.rb                 | 2 +-
 8 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/lib/whimsy/asf/committee.rb b/lib/whimsy/asf/committee.rb
index 0798332..54829a5 100644
--- a/lib/whimsy/asf/committee.rb
+++ b/lib/whimsy/asf/committee.rb
@@ -184,7 +184,7 @@ module ASF
       todos.each do |resolution|
         pmc = resolution['display_name']
         if resolution['action'] == 'terminate'
-          block.sub! %r{^    #{pmc.ljust(22)} # .*\n}, ''
+          block.sub! %r{^    #{Regexp.escape(pmc).ljust(22)} # .*\n}, ''
         elsif resolution['action'] == 'establish' and not existing.include? pmc
           block += "    #{pmc.ljust(22)} # new, monthly through #{month}\n"
         end
@@ -320,7 +320,7 @@ module ASF
       #         remove from COMMITTEE MEMBERSHIP AND CHANGE PROCESS          #
       ########################################################################
 
-      contents.sub! %r{^\* #{pmc}  ?\(est.*?\n\n+}m, ''
+      contents.sub! %r{^\* #{Regexp.escape(pmc)}  ?\(est.*?\n\n+}m, ''
 
       contents
     end
diff --git a/lib/whimsy/asf/yaml.rb b/lib/whimsy/asf/yaml.rb
index 58c577d..4b7a59a 100644
--- a/lib/whimsy/asf/yaml.rb
+++ b/lib/whimsy/asf/yaml.rb
@@ -57,7 +57,7 @@ module YamlFile
     # replace the old section with the new one
     # assume it is delimited by the key and '...' or another key.
     # Keys may be symbols. Only handles top-level key matching.
-    range = %r{^#{key.inspect}:\s*$.*?(?=^(:?\w+:|\.\.\.)$)}m
+    range = %r{^#{Regexp.escape(key.inspect)}:\s*$.*?(?=^(:?\w+:|\.\.\.)$)}m
     output[range] = new_section
 
     output
diff --git a/www/board/agenda/models/minutes.rb 
b/www/board/agenda/models/minutes.rb
index 940e868..f80aa99 100755
--- a/www/board/agenda/models/minutes.rb
+++ b/www/board/agenda/models/minutes.rb
@@ -146,7 +146,7 @@ class Minutes
 
     missing = minutes.scan(/^Attachment (\w\w?):.*\s*\n---/).flatten
     missing.each do |attach|
-      minutes.sub! /^(\s+)See Attachment #{attach}$/, '\1No report was 
submitted.'
+      minutes.sub! /^(\s+)See Attachment #{Regexp.escape(attach)}$/, '\1No 
report was submitted.'
     end
 
     minutes.sub! 'Minutes (in Subversion) are found under the URL:',
diff --git a/www/board/agenda/views/actions/attend.json.rb 
b/www/board/agenda/views/actions/attend.json.rb
index d3a4bed..0ece18b 100644
--- a/www/board/agenda/views/actions/attend.json.rb
+++ b/www/board/agenda/views/actions/attend.json.rb
@@ -19,7 +19,7 @@ Agenda.update(@agenda, message) do |agenda|
 
   if directors.include? @name
 
-    updated = directors.sub /^ .*#{@name}.*?\n/, ''
+    updated = directors.sub /^ .*#{Regexp.escape(@name)}.*?\n/, ''
 
     if @action == 'regrets'
       updated[/Absent:\n\n.*?\n()\n/m, 1] = "        #{@name}\n"
@@ -41,7 +41,7 @@ Agenda.update(@agenda, message) do |agenda|
 
   elsif officers.include? @name
 
-    updated = officers.sub /^ .*#{@name}.*?\n/, ''
+    updated = officers.sub /^ .*#{Regexp.escape(@name)}.*?\n/, ''
 
     if @action == 'regrets'
       updated[/Absent:\n\n.*?\n()\n/m, 1] = "        #{@name}\n"
@@ -56,7 +56,7 @@ Agenda.update(@agenda, message) do |agenda|
 
   elsif @action == 'regrets'
 
-    updated = guests.sub /^ .*#{@name}.*?\n/, ''
+    updated = guests.sub /^ .*#{Regexp.escape(@name)}.*?\n/, ''
     updated.sub! /:\n\n\n/, ":\n\n        none\n"
 
     rollcall.sub! guests, updated
diff --git a/www/board/agenda/views/actions/posted-reports.json.rb 
b/www/board/agenda/views/actions/posted-reports.json.rb
index c927805..6ff2bb8 100755
--- a/www/board/agenda/views/actions/posted-reports.json.rb
+++ b/www/board/agenda/views/actions/posted-reports.json.rb
@@ -76,8 +76,8 @@ _ reports do |path, mail|
   _path path
 
   subject = mail.subject.downcase
-  _missing missing.any? {|title| subject =~ /\b#{title}\b/}
+  _missing missing.any? {|title| subject =~ /\b#{Regexp.escape(title)}\b/}
 
-  item = parsed.find {|item| subject =~ /\b#{item['title'].downcase}\b/}
+  item = parsed.find {|item| subject =~ 
/\b#{Regexp.escape(item['title'].downcase)}\b/}
   _title item['title'] if item
 end
diff --git a/www/board/posted-reports.cgi b/www/board/posted-reports.cgi
index 669e248..ab5e086 100755
--- a/www/board/posted-reports.cgi
+++ b/www/board/posted-reports.cgi
@@ -94,7 +94,7 @@ _html do
               _td do
               # ERB::Util.url_encode changes space to %20 as required in the 
path component
               href = THREAD + ERB::Util.url_encode('<' + mail.message_id + '>')
-                if missing.any? {|title| mail.subject.downcase =~ 
/\b#{title}\b/}
+                if missing.any? {|title| mail.subject.downcase =~ 
/\b#{Regexp.escape(title)}\b/}
                   _td do
                     _a.missing mail.subject, href: href
                   end
@@ -120,9 +120,9 @@ _json do
     _link THREAD + ERB::Util.url_encode('<' + mail.message_id + '>')
 
     subject = mail.subject.downcase
-    _missing missing.any? {|title| subject =~ /\b#{title}\b/}
+    _missing missing.any? {|title| subject =~ /\b#{Regexp.escape(title)}\b/}
 
-    item = parsed.find {|item| subject =~ /\b#{item['title'].downcase}\b/}
+    item = parsed.find {|item| subject =~ 
/\b#{Regexp.escape(item['title'].downcase)}\b/}
     _title item['title'] if item
   end
 end
diff --git a/www/members/nominations.cgi b/www/members/nominations.cgi
index 037d33f..b1b9165 100755
--- a/www/members/nominations.cgi
+++ b/www/members/nominations.cgi
@@ -130,7 +130,7 @@ _html do
               href = MBOX + mail.date.strftime('%Y%m') + '.mbox/' +
               ERB::Util.url_encode('<' + mail.message_id + '>')
 
-              if nominees.any? {|name| mail.subject =~ /\b#{name}\b/i}
+              if nominees.any? {|name| mail.subject =~ 
/\b#{Regexp.escape(name)}\b/i}
                 _a.present mail.subject, href: href
               else
                 _a.missing mail.subject, href: href
@@ -149,6 +149,6 @@ _json do
   _ reports do |mail| # TODO: reports is not defined
     _subject mail.subject
     _link MBOX + ERB::Util.url_encode('<' + mail.message_id + '>') # TODO 
looks wrong: does not agree with href above
-    _missing missing.any? {|title| mail.subject.downcase =~ /\b#{title}\b/}
+    _missing missing.any? {|title| mail.subject.downcase =~ 
/\b#{Regexp.escape(title)}\b/}
   end
 end
diff --git a/www/roster/views/actions/ppmc.json.rb 
b/www/roster/views/actions/ppmc.json.rb
index 01dbe55..c430a0f 100644
--- a/www/roster/views/actions/ppmc.json.rb
+++ b/www/roster/views/actions/ppmc.json.rb
@@ -106,7 +106,7 @@ if env.password
           end
         else
           podlings.sub! pre do |element|
-            element.sub! /\s+<mentor username=#{id.inspect}>.*<\/mentor>/, ''
+            element.sub! /\s+<mentor 
username=#{Regexp.escape(id.inspect)}>.*<\/mentor>/, ''
             element
           end
         end

Reply via email to