You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2022/04/14 13:13:43 UTC

[whimsy] branch master updated: Allow for a filter

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 aec69836 Allow for a filter
aec69836 is described below

commit aec69836569e48f7374abc83229bfedd4324fe5e
Author: Sebb <se...@apache.org>
AuthorDate: Thu Apr 14 14:13:36 2022 +0100

    Allow for a filter
---
 www/members/mailing_lists.cgi | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/www/members/mailing_lists.cgi b/www/members/mailing_lists.cgi
index a8a333db..5a193504 100755
--- a/www/members/mailing_lists.cgi
+++ b/www/members/mailing_lists.cgi
@@ -22,7 +22,7 @@ FLAGS = %{
 -mz moderate after checking sender is known
 -Mz unmoderated, but requires sender to be known
 
--s subscriptions are moderated
+-s subscriptions are moderated (i.e. private list)
 
 -x check mime-type, size etc
 -y send copy to security@apache.org
@@ -39,6 +39,21 @@ def type(mu)
   }[mu.to_sym]
 end
 
+query = ENV['QUERY_STRING']
+# Only allow letters in the query string so it is safe to use
+if query =~ %r{^filter=([a-zA-Z]+)$}
+  # Convert xmU into m.......U..x
+  letters = []
+  $1.split('').sort_by(&:upcase).each_cons(2).with_index do |(a, b), i|
+    letters << a if i == 0
+    (b.upcase.ord - a.upcase.ord - 1).times {letters << '.'}
+    letters << b
+  end
+  filter = Regexp.new(letters.join)
+else
+  filter = nil
+end
+
 _html do
   _body? do
     _whimsy_body(
@@ -72,7 +87,7 @@ _html do
         _thead_ do
           _tr do
             _th 'list', data_sort: 'string'
-            _th 'flags', data_sort: 'string'
+            _th "flags #{filter}", data_sort: 'string'
             _th 'Type (mu)', data_sort: 'string'
             _th 'Known (z)', data_sort: 'string'
             _th 'Private (s)', data_sort: 'string'
@@ -81,7 +96,7 @@ _html do
           end
         end
         _tbody do
-          ASF::Mail.parse_flags do |domain, list, flags|
+          ASF::Mail.parse_flags(filter) do |domain, list, flags|
             mu = flags.tr('^muMU', '')
             _tr do
               _td data_sort_value: "#{domain}-#{list}" do