View Issue Details

This bug affects 1 person(s).
 10
IDProjectCategoryView StatusLast Update
16902Bug reportsSurvey editingpublic2021-03-15 15:39
ReporterDenisChenu Assigned Togabrieljenik  
PrioritynoneSeverityminor 
Status closedResolutionfixed 
Product Version3.25.3 
Summary16902: publicurl disable attchments
Description

After https://github.com/LimeSurvey/LimeSurvey/pull/1679, if you set a publicurl : no attachments is saved

Steps To Reproduce

Git checkout
Set 'publicurl' => "http://limesurvey.example.org/",

Try to save a attachements.

Additional Information

Even if http://limesurvey.example.org/ is your admin URL : it broke.
You can try yourself

Issue is here :
Yii::app()->getConfig('uploadurl') return /upload or limesurvey\upload and systeml remove strlen(http://limesurvey.example.org) caracter …

Valid test :
strlen(rtrim('/',Yii::app()->getBaseUrl(false))

TagsNo tags attached.
Bug heat10
Complete LimeSurvey version number (& build)3.25.3 github
I will donate to the project if issue is resolvedNo
Browsernot relevant
Database type & versionnot relevant
Server OS (if known)fedora/linux
Webserver software & version (if known)not relevant
PHP Versionnot relevant

Relationships

child of 16854 closedgabrieljenik Cannot attach PDF to email invitation (email template for surveys) 

Users monitoring this issue

There are no users monitoring this issue.

Activities

cdorin

cdorin

2020-12-29 16:56

reporter   ~61278

Hello Denis - I am not sure if I understand how to reproduce it - could you please provide more info about it?

DenisChenu

DenisChenu

2020-12-29 18:21

developer   ~61294

Last edited: 2020-12-29 18:22

You have to update your config.php file

        'debug'=>2,
        'debugsql'=>0, // Set this to 1 to enanble sql logging, only active when debug = 2
        'publicurl' => 'https://limesurvey.org/limesurvey',

https://manual.limesurvey.org/Optional_settings#Advanced_path_settings

This settings is available in config.php and it is used when LimeSurvey need an absolute url (for example when token emails are sent).

You can use the real url or a false.

It's used a lot when there are proxy between internet and limesurvey.

This param muts be used only for sending absoluteurl.

gabrieljenik

gabrieljenik

2021-01-05 14:15

manager   ~61431

PR: https://github.com/LimeSurvey/LimeSurvey/pull/1707

For master this also applied?
What do you think @DenisChenu?

For develop, I believe we should have a central method for resolving the url base.
What do you think @ollehar?

DenisChenu

DenisChenu

2021-01-05 14:34

developer   ~61433

Yes, issue surely in master.

I don't understand why we need to save aboslute URL here ? And how we get the absolute url : seems we don't use same system on both system :

In GUI : we seem to use a methode, but when load another method : we need to use same method.

DenisChenu

DenisChenu

2021-01-05 14:35

developer   ~61434

PS : why don't save path (relative to rootdir) and not url ?

ollehar

ollehar

2021-02-19 15:42

administrator   ~62406

Fixed in master only? (LS4)

DenisChenu

DenisChenu

2021-02-19 15:47

developer   ~62407

Fixed in master only? (LS4)

reported for 3.X

DenisChenu

DenisChenu

2021-02-19 15:50

developer   ~62408

PS : my diff with the fix for windows :

diff --git a/application/controllers/admin/emailtemplates.php b/application/controllers/admin/emailtemplates.php
old mode 100644
new mode 100755
index 21e8b52ad7771b9ed088f3f67e368b216f765c87..06973e94bb9db81247f86532616a347f1750f446
--- a/application/controllers/admin/emailtemplates.php
+++ b/application/controllers/admin/emailtemplates.php
@@ -99,7 +99,7 @@ class emailtemplates extends Survey_Common_Action
      */
     function update($iSurveyId)
     {
-        $uploadUrl = Yii::app()->getBaseUrl(true).substr(Yii::app()->getConfig('uploadurl'), strlen(Yii::app()->getConfig('publicurl')) - 1);
+        $uploadUrl = Yii::app()->getBaseUrl(true).substr(Yii::app()->getConfig('uploadurl'), strlen(rtrim(Yii::app()->getBaseUrl(false))));
         // We need the real path since we check that the resolved file name starts with this path.
         $uploadDir = realpath(Yii::app()->getConfig('uploaddir'));
         $sSaveMethod = Yii::app()->request->getPost('save', '');
@@ -112,7 +112,8 @@ class emailtemplates extends Survey_Common_Action
                     foreach ($_POST['attachments'][$langname] as $template => &$attachments) {
                         foreach ($attachments as  $index => &$attachment) {
                             // We again take the real path.
-                            $localName = realpath(urldecode(str_replace($uploadUrl, $uploadDir, $attachment['url'])));
+                           $check = str_replace("/",DIRECTORY_SEPARATOR, urldecode(str_replace($uploadUrl, $uploadDir, $attachment['url'])));
+                            $localName = realpath($check);
                             if ($localName !== false) {
                                 if (strpos($localName, $uploadDir) === 0) {
                                     $attachment['url'] = $localName;
diff --git a/application/views/admin/emailtemplates/email_language_template_tab.php b/application/views/admin/emailtemplates/email_language_template_tab.php
old mode 100644
new mode 100755
index 48f5c42169b11e67dc6165d66c836ad32f26732c..430873ce7bd6f55628dc65b5330164ca6d4c92d8
--- a/application/views/admin/emailtemplates/email_language_template_tab.php
+++ b/application/views/admin/emailtemplates/email_language_template_tab.php
@@ -64,7 +64,7 @@ $script = array();
     $hideAttacehemtTable = true;
     if (isset($esrow->attachments[$tab])) {
         foreach ($esrow->attachments[$tab] as $attachment) {
-            $script[] = sprintf("prepEmailTemplates.addAttachment($('#attachments-%s-%s'), %s, %s, %s );", $grouplang, $tab, json_encode($attachment['url']), json_encode($attachment['relevance']), json_encode($attachment['size']));
+            $script[] = sprintf("prepEmailTemplates.addAttachment($('#attachments-%s-%s'), %s, %s, %s );", $grouplang, $tab, '"'.addslashes(addslashes($attachment['url'])).'"', json_encode($attachment['relevance']), json_encode($attachment['size']));
         }
         $hideAttacehemtTable = false;
     }
ollehar

ollehar

2021-02-19 16:05

administrator   ~62417

Better instructions needed on how to reproduce.

DenisChenu

DenisChenu

2021-02-19 16:07

developer   ~62419

  1. Set 'publicurl' => 'http://limesurvey.example.org/', in config.php
  2. Go to edit email template
  3. Click on Add file in Invitation attachments:
  4. choose or upload a file
  5. Save
  6. Check if file is still there.

Maybe next time i make directly the fix … :/

ollehar

ollehar

2021-02-19 16:08

administrator   ~62420

Even if you do the fix yourself we still have to test it.

ollehar

ollehar

2021-02-19 16:09

administrator   ~62421

Remember: We have non-technical people doing QA as well. Instructions need to be clear.

gabrieljenik

gabrieljenik

2021-03-11 18:28

manager   ~63320

Fix committed to 3.x-LTS branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=31316

lime_release_bot

lime_release_bot

2021-03-15 15:39

administrator   ~63381

Fixed in Release 3.25.18+210316

Related Changesets

LimeSurvey: 3.x-LTS 92eda114

2021-03-11 19:20

gabrieljenik

Committer: GitHub


Details Diff
Fixed issue 16902: publicurl disable attchments (#1707) Affected Issues
16902
mod - application/controllers/admin/emailtemplates.php Diff File

Issue History

Date Modified Username Field Change
2020-12-11 14:45 DenisChenu New Issue
2020-12-11 14:45 DenisChenu Relationship added child of 16854
2020-12-29 16:56 cdorin Note Added: 61278
2020-12-29 18:21 DenisChenu Note Added: 61294
2020-12-29 18:22 DenisChenu Note Edited: 61294
2021-01-05 14:15 gabrieljenik Note Added: 61431
2021-01-05 14:34 DenisChenu Note Added: 61433
2021-01-05 14:35 DenisChenu Note Added: 61434
2021-01-06 21:08 gabrieljenik Issue cloned: 16950
2021-02-19 15:42 ollehar Assigned To => ollehar
2021-02-19 15:42 ollehar Status new => feedback
2021-02-19 15:42 ollehar Note Added: 62406
2021-02-19 15:47 DenisChenu Note Added: 62407
2021-02-19 15:47 DenisChenu Status feedback => assigned
2021-02-19 15:50 DenisChenu Note Added: 62408
2021-02-19 16:05 ollehar Status assigned => feedback
2021-02-19 16:05 ollehar Note Added: 62417
2021-02-19 16:07 DenisChenu Note Added: 62419
2021-02-19 16:07 DenisChenu Status feedback => assigned
2021-02-19 16:08 ollehar Note Added: 62420
2021-02-19 16:09 ollehar Note Added: 62421
2021-03-09 16:50 DenisChenu Assigned To ollehar => DenisChenu
2021-03-11 18:21 ollehar Status assigned => resolved
2021-03-11 18:21 ollehar Resolution open => fixed
2021-03-11 18:28 gabrieljenik Changeset attached => LimeSurvey 3.x-LTS 92eda114
2021-03-11 18:28 gabrieljenik Note Added: 63320
2021-03-11 18:28 gabrieljenik Assigned To DenisChenu => gabrieljenik
2021-03-15 15:39 lime_release_bot Note Added: 63381
2021-03-15 15:39 lime_release_bot Status resolved => closed