Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom_input fail with 6.2.48 #846

Closed
aepli opened this issue Jan 21, 2020 · 7 comments · Fixed by #848
Closed

custom_input fail with 6.2.48 #846

aepli opened this issue Jan 21, 2020 · 7 comments · Fixed by #848
Labels
bug ready A PR is waiting to be merged. Close to be solved
Milestone

Comments

@aepli
Copy link
Contributor

aepli commented Jan 21, 2020

Version

Sympa 6.2.48

Installation method

From source

Expected behavior

custom_input should be usable in the list creation form as in the versions of Sympa up to 6.2.22.

Actual behavior

if using custom_input.visibility in the Request a List form, when using the "submit your creation request" button, the request is not processed and an error message is displayed:

Internal Server Error

Sympa encountered an internal error.

Please contact the listmaster.

Erreurs : Can't use string ("conceal") as a HASH ref while "strict refs" in use at /home/sympa/lib/sympa/cgi/wwsympa.fcgi line 2114.
Traceback

DIED: Can't use string ("conceal") as a HASH ref while "strict refs" in use at /home/sympa/lib/sympa/cgi/wwsympa.fcgi line 2114.
 at /home/sympa/lib/sympa/cgi/wwsympa.fcgi line 2114.
	main::get_parameters('listesdev.unige.ch') called at /home/sympa/lib/sympa/cgi/wwsympa.fcgi line 1246

Additional information

OS: Debian GNU/Linux 9.11 (stretch)
Perl: 5.24.1-3+deb9u5 amd64

The log message:

Jan 21 16:12:08 lunimlsdev4 wwsympa[44023]: err main::#1246 > main::get_parameters#2114 DIED: Can't use string ("conceal") as a HASH ref while "strict refs" in use at /home/sympa/lib/sympa/cgi/wwsympa.fcgi line 2114.

scenario_label.tt2:

[% scenario_label = {
    visibility = {
        conceal = {
            title_default = "conceal except for subscribers"
        }
        noconceal = {
            default = "1"
            title_default = "no conceal"
        }
        secret = {
            title_default = "conceal even for subscribers"
        }
        intranet = {
            title_default = "intranet access"
        }
    }
}%]

create_list_request.tt2:

<!-- create_list_request.tt2 -->

<!-- Add scenario_label variable -->
[%- PROCESS scenario_label.tt2 -%]
<!-- End scenario_label -->

<div class="block" id="create_switch">
    <div id="list_create">
        <form action="[% path_cgi %]" method="post">
            <fieldset>
                <label for="listname">[%|loc%]List name:[%END%]</label>
                <div style="display: flex; vertical-align: middle;">
                    <input type="text" id="listname" name="listname" size="30" value="[% saved.listname %]" style="width: 40%; margin-bottom: 5px;" />
                    <span style="padding-left: 0.2em; font-size: 1.9em; font-weight: bold; color: #CF0063;">@unige.ch</span>
                </div>

                <label for="privilegedowner">[%|loc%]Privileged owner[%END%]:</label> <span>[% user.email %]</span>

                <label for="owners">[%|loc%]Email address of owners:[%END%]</label>
                    <blockquote>
                        [%- FOREACH i IN [1..5] %]
                            <label for="owner[% i %]">[%|loc%]Owner's email[%END%] n°[% i %]</label>
                            <input type="text" name="custom_input.mgr[% i %]" size="40" value="" />
                        [%- END %]
                    </blockquote>

                <label for="list_type">[%|loc%]List type:[%END%]</label>
                <ul id="list_type">
                    [%~ FOREACH tpl_info = list_list_tpl %]
                        <li>
                            <input type="radio" name="template" value="[% tpl_info.key %]"
                                   [% IF tpl_info.value.selected || loop.size == 1 %] checked="checked" [% END %]
                                   id="template.[% tpl_info.key %]" />
                            <label for="template.[% tpl_info.key %]">
                                [% IF tpl_info.value.title ~%]
                                    [% tpl_info.value.title %]
                                [%~ ELSE ~%]
                                    [% tpl_info.key %]
                                [%~ END %]
                            </label>
                            [%~ IF tpl_info.value.html_content ~%]
                                [% TRY ~%]
                                    [% tpl_info.value.html_content | eval %]
                                [%~ CATCH ~%]
                                    <!-- [% error | html %] -->
                                [%~ END %]
                            [%~ END %]
                        </li>
                    [%~ END %]
                </ul>

                <label for="visibility">[%|loc%]Visibility:[%END%]</label>
                <select name="custom_input.visibility">
                    [%- FOREACH sc = scenario_label.visibility %]
                        <option value="[% sc.key %]" [%- IF sc.value.default -%]selected="selected"[%- END -%]>
                            [%- IF sc.value.title %]
                                [%- IF session.lang == "de_DE" %] [% sc.value.title.de %]
                                [%- ELSIF session.lang == "fr_FR" %] [% sc.value.title.fr %]
                                [%- ELSIF session.lang == "it_IT" %] [% sc.value.title.it %]
                                [%- ELSE %] [% sc.value.title.us %] [% END %]
                            [%- ELSE %]
                                [% |loc %][% sc.value.title_default %][% END %]
                            [%- END %]
                        </option>
                    [%- END %]
                </select>

                <label for="subject">[%|loc%]Subject:[%END%]</label>
                <input type="text" name="subject" id="subject" size="60" value="[% saved.subject %]" />

                [% SET single_topic = 1 ~%]
                [% FOREACH topic = list_of_topics ~%]
                    [% IF loop.size > 1 || (topic.key && topic.key != "other") ~%]
                        [% SET single_topic = 0 ~%]
                        [% LAST %]
                    [%~ END ~%]
                [%~ END ~%]
                [% IF single_topic ~%]
                    <input id="topics" name="topics" type="hidden" value="other" />
                [%~ ELSE ~%]
                    <label for="topics">[%|loc%]Audience:[%END%]</label>
                    <select id="topics" name="topics">
                        <option value="">[%|loc%]-- Select an Audience --[%END%]</option>
                        [% FOREACH topic = list_of_topics ~%]
                            [% IF topic.key == "other" ~%]
                                [% NEXT %]
                            [%~ END ~%]
                            <option value="[% topic.key %]"
                                    [%~ IF topic.value.selected %] selected="selected"[% END %]>
                               [%~ topic.key | optdesc('listtopic') ~%]
                            </option>
                        [% END %]
                        <option value="other">[%|loc%]Other[%END%]</option>
                    </select>
                    <br />
                [%~ END %]

                <label for="info" class="align_top">[%|loc%]Description:[%END%]</label>
                <textarea class="desc" id="info" name="info" rows="10" cols="80">[% saved.info %]</textarea>
                <input class="MainMenuLinks" type="submit" name="action_create_list" value="[%|loc%]Submit your creation request[%END%]" />
            </fieldset>
        </form>

    </div>

    [% IF all_lists.size > 0 %]
        <div id="list_copy">
            <p>
                [%|loc%]You can create a list by using another existing list as a template.  The configuration will be copied to the new list. Please note that neither the list members, archives, nor shared documents will be duplicated. Only the lists you own may be used as templates.[%END%]
                [%|loc%]After the list is created, you will be able to modify the configuration.[%END%]
            </p>

            <form action="[% path_cgi %]" method="post">
                <fieldset>
                    <select name="list">
                        [% FOREACH l = all_lists %]
                            <option value="[% l.name %]">[% l.name %]</option>
                        [% END %]
                    </select>
                    <label for="new_listname">[%|loc%]New list name:[%END%]</label>
                    <input id="new_listname"     name="new_listname" value="" />
                    <input type="hidden"         name="new_robot"    value=[%robot%] />
                    <input class="MainMenuLinks" type="submit"       name="action_copy_list" value="[%|loc%]copy list configuration[%END%]" />
                </fieldset>
            </form>
        </div>
    [% END %]

</div>

[%# Initialize toggle. #%]
<script>
<!--
    $('#list_copy').hide();

    $('a[href="#list_copy"], a[href="#list_create"]').on('click', function(e) {
        e.stopPropagation();
        e.preventDefault();
        id = $(this).attr('href').substr(1);
        $('#list_copy, #list_create').hide();
        $('#' + id).show();
        return false;
    });
//-->
</script>

<!-- end create_list_request.tt2 -->
@ikedas
Copy link
Member

ikedas commented Jan 22, 2020

Hi @aepli ,

Could you please show us these things?

  • Steps to reproduce the bug you reported (e.g. 'go to "..." page, click "..." button, ...').
  • Log entries recorded during the steps above.

Thanks.

@ikedas
Copy link
Member

ikedas commented Jan 23, 2020

@aepli ,

Could you please apply this patch and check if the problem will be solved?

@ikedas ikedas added bug ready A PR is waiting to be merged. Close to be solved labels Jan 23, 2020
@aepli
Copy link
Contributor Author

aepli commented Jan 23, 2020

Hi @aepli ,

Could you please show us these things?

* Steps to reproduce the bug you reported (e.g. 'go to "..." page, click "..." button, ...').

* Log entries recorded during the steps above.

Thanks.

Hi @ikedas,
Sorry for my late reply, I do not work on Sympa full time.

Here are the steps to reproduce the problem:

  • From the Sympa Web interface after having authenticated.
  • Click on the Request a List option
  • Fill in the fields List name, Owner's email n ° 1, Subject and Description
  • Select the type of list "Confidential list setup", Visibility "no conceal" and choose the Audience
  • Click on the "Submit your creation request" button

The error message is then displayed and no list creation request is saved.

Here is the template for Confidential list setup:

subject [% subject %]

status [% status %]

[% IF topics -%]
topics [% topics %]
[% END %]

visibility [% custom_input.visibility %]

send confidential

reject_mail_from_automates_feature on

process_archive off

archive
web_access closed
mail_access closed
quota 102400
max_month 12
period month
archive_crypted_msg original
web_archive_spam_protection cookie

clean_delay_queuemod 15

reply_to_header
value list
apply forced

subscribe closed

add auth

unsubscribe closed

del auth

review owner

invite closed

info private

custom_subject [% listname %]

digest 5 20:56

[% FOREACH o = owner -%]
owner
  email [% o.email %]
  profile privileged
  reception nomail
  visibility conceal
  [% IF o.gecos -%]
  gecos [% o.gecos %]
  [% END %]

[% END %]

[% FOREACH mgr IN ['mgr1','mgr2','mgr3','mgr4','mgr5'] %]
[% IF custom_input.$mgr %]
owner
  email [% custom_input.$mgr %]
  profile normal
  reception mail
  visibility noconceal
[% END %]
[% END %]

[% IF editor -%]
[% FOREACH e = editor -%]
editor
  email [% e.email %]

[% END %]
[% END %]

shared_doc
quota 0
d_edit listmaster
d_read listmaster

pictures_feature on

creation
  date [% creation.date %]
  date_epoch [% creation.date_epoch %]
[% IF creation_email -%]
  email [% creation_email %]
[% END %]

serial 0

@aepli
Copy link
Contributor Author

aepli commented Jan 23, 2020

Hi @ikedas,
No, the patch does not correct the problem, the error message is the same.

If I understand the error message, the problem is on line 2114.
It is the call of the $log->syslog method which generates the error.

If I comment on lines 2114 to 2116, there is no more error. But this disables log for debug level 2!

@@ -2111,9 +2111,9 @@
         } elsif ($pname =~ /^custom_input(.*)$/) {
             my $key = $tokens[1];
             $regexp = $in_regexp{'custom_input'};
-            $log->syslog('debug2',
-                "get_parameters (custom_input) : ($p)($key) $pname $in{$p} $Conf::Conf{$key}{type}"
-            );
+           #$log->syslog('debug2',
+           #     "get_parameters (custom_input) : ($p)($key) $pname $in{$p} $Conf::Conf{$key}{type}"
+           #);
             $custom_input->{$key} = $in{$p};
             undef $in{$p};
         } elsif ($in_regexp{$pname}) {

I think there must be a problem with $Conf::Conf{$key}{type}, but I'm not sure.

Regards.

@ikedas ikedas removed the ready A PR is waiting to be merged. Close to be solved label Jan 24, 2020
@ikedas
Copy link
Member

ikedas commented Jan 24, 2020

@aepli , how about this?

index 8d0a09f..a97ba6b 100644
--- a/src/cgi/wwsympa.fcgi.in
+++ b/src/cgi/wwsympa.fcgi.in
@@ -2108,12 +2108,11 @@ sub get_parameters {
                 unless defined $plugin->{$plugin_name};
             $plugin->{$plugin_name}{$param_name} = $in{$p};
             undef $in{$p};
-        } elsif ($pname =~ /^custom_input(.*)$/) {
+        } elsif ($pname eq 'custom_input') {
             my $key = $tokens[1];
             $regexp = $in_regexp{'custom_input'};
-            $log->syslog('debug2',
-                "get_parameters (custom_input) : ($p)($key) $pname $in{$p} $Conf::Conf{$key}{type}"
-            );
+            $log->syslog('debug2', '(%s) %s', $p, $in{$p});
+            $custom_input ||= {};
             $custom_input->{$key} = $in{$p};
             undef $in{$p};
         } elsif ($in_regexp{$pname}) {
@@ -2180,7 +2179,7 @@ sub get_parameters {
     }

     $in{custom_attribute} = $custom_attribute;
-    $in{custom_input}     = $custom_input;
+    $in{custom_input}     = $custom_input if $custom_input;
     $in{plugin}           = $plugin;

     return 1;

And, will custom_input parameters be handled properly with this change?

@ikedas ikedas added the ready A PR is waiting to be merged. Close to be solved label Jan 24, 2020
@aepli
Copy link
Contributor Author

aepli commented Jan 24, 2020

@ikedas, excellent no more error in Apache and Perl no longer "dies"!

The custom_input parameter is correctly processed.

Thank you so much.

Regards.

@aepli aepli closed this as completed Jan 24, 2020
ikedas added a commit that referenced this issue Jan 24, 2020
Bug: Crash by assigning to uninitialized hashref (#846)
@ikedas
Copy link
Member

ikedas commented Jan 25, 2020

@aepli , thanks for reporting bug and confirming fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ready A PR is waiting to be merged. Close to be solved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants