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 ebfebab Allow for possible meta-chars
ebfebab is described below
commit ebfebabe7a604ad4a8031541df393a6dca87e9f0
Author: Sebb <[email protected]>
AuthorDate: Thu Feb 18 17:20:38 2021 +0000
Allow for possible meta-chars
---
www/board/agenda/views/pages/adjournment.js.rb | 2 +-
www/board/agenda/views/pages/backchannel.js.rb | 2 +-
www/board/agenda/views/pages/report.js.rb | 4 ++--
www/board/agenda/views/pages/search.js.rb | 2 +-
www/roster/views/ppmc/graduate.js.rb | 2 +-
www/roster/views/utils.js.rb | 6 ++++++
6 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/www/board/agenda/views/pages/adjournment.js.rb
b/www/board/agenda/views/pages/adjournment.js.rb
index 50d768c..e34ef4b 100644
--- a/www/board/agenda/views/pages/adjournment.js.rb
+++ b/www/board/agenda/views/pages/adjournment.js.rb
@@ -197,7 +197,7 @@ class PMCActions < Vue
resolution = {
action: todo_type,
name: todo.name,
- display_name: item.title.sub(/^#{todo_type} /i, '').
+ display_name: item.title.sub(/^#{escapeRegExp(todo_type)} /i,
'').
sub(/ Chair$/i, ''),
title: item.title,
minutes: minutes,
diff --git a/www/board/agenda/views/pages/backchannel.js.rb
b/www/board/agenda/views/pages/backchannel.js.rb
index 54c7e08..253263b 100644
--- a/www/board/agenda/views/pages/backchannel.js.rb
+++ b/www/board/agenda/views/pages/backchannel.js.rb
@@ -58,7 +58,7 @@ class Backchannel < Vue
# highlight mentions of my id
def mention(text)
- return text.gsub(/<.*?>|\b(#{User.userid})\b/) do |match|
+ return text.gsub(/<.*?>|\b(#{escapeRegExp(User.userid)})\b/) do |match|
match[0] == '<' ? match : "<span class=mention>#{match}</span>"
end
end
diff --git a/www/board/agenda/views/pages/report.js.rb
b/www/board/agenda/views/pages/report.js.rb
index f23c5f4..d2e4125 100644
--- a/www/board/agenda/views/pages/report.js.rb
+++ b/www/board/agenda/views/pages/report.js.rb
@@ -180,7 +180,7 @@ class Report < Vue
@@item.people.each_pair do |id, person|
# email addresses in 'Establish' resolutions and (ids) everywhere
- text.gsub! /(\(|<)(#{id})( at |@|\))/ do |m, pre, id, post|
+ text.gsub! /(\(|<)(#{escapeRegExp(id)})( at |@|\))/ do |m, pre, id,
post|
if person.icla
if post == ')' and person.member
"#{pre}<b><a href='#{roster}#{id}'>#{id}</a></b>#{post}"
@@ -215,7 +215,7 @@ class Report < Vue
ok ||= names.all? {|part| iclas.any? {|icla| icla.include? part}}
ok ||= iclas.all? {|part| names.any? {|name| name.include? part}}
if @@item.title =~ /^Establish/ and not ok
- text.gsub! /#{escapeRegExp("#{id}'>#{person.name}")}/,
+ text.gsub! /#{escapeRegExp("#{id}'>#{escapeRegExp(person.name)}")}/,
"?q=#{encodeURIComponent(person.name)}'>" +
"<span class='commented'>#{person.name}</span>"
else
diff --git a/www/board/agenda/views/pages/search.js.rb
b/www/board/agenda/views/pages/search.js.rb
index eeab591..8ecc272 100644
--- a/www/board/agenda/views/pages/search.js.rb
+++ b/www/board/agenda/views/pages/search.js.rb
@@ -34,7 +34,7 @@ class Search < Vue
item.text.split(/\n\s*\n/).each do |paragraph|
if paragraph.downcase().include? text
_pre.report domPropsInnerHTML:
- htmlEscape(paragraph).gsub(/(#{text})/i,
+ htmlEscape(paragraph).gsub(/(#{escapeRegExp(text)})/i,
"<span class='hilite'>$1</span>")
end
end
diff --git a/www/roster/views/ppmc/graduate.js.rb
b/www/roster/views/ppmc/graduate.js.rb
index 395d1aa..c12329f 100644
--- a/www/roster/views/ppmc/graduate.js.rb
+++ b/www/roster/views/ppmc/graduate.js.rb
@@ -63,7 +63,7 @@ class PPMCGraduate < Vue
jQuery('#graduate').on('show.bs.modal') do |event|
@project = @@ppmc.display_name
@description = @@ppmc.description.gsub(/\s+/, ' ').strip().
- sub(/^(Apache )?#{@@ppmc.display_name}\s(is )?/, '').sub(/\.$/, '')
+ sub(/^(Apache )?#{Utils.escapeRegExp(@@ppmc.display_name)}\s(is )?/,
'').sub(/\.$/, '')
self.resize(textarea)
diff --git a/www/roster/views/utils.js.rb b/www/roster/views/utils.js.rb
index 1d68c68..9883251 100644
--- a/www/roster/views/utils.js.rb
+++ b/www/roster/views/utils.js.rb
@@ -1,5 +1,11 @@
class Utils
+ # escape a string so that it can be used as a regular expression
+ def self.escapeRegExp(string)
+ #
https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions
+ return string.gsub(/([.*+?^=!:${}()|\[\]\/\\])/, "\\$1");
+ end
+
# Common processing to handle a response that is expected to be JSON
def self.handle_json(response, success)
content_type = response.headers.get('content-type') || ''