View Issue Details

This bug affects 1 person(s).
 18
IDProjectCategoryView StatusLast Update
05066Bug reportsTheme editorpublic2011-05-04 19:31
Reporteruser13073Assigned Toc_schmitz  
PriorityurgentSeveritypartial_block 
Status closedResolutionfixed 
Product Version1.91RC5 
Fixed in Version1.91 
Summary05066: GSOC: Template editor malfunction: Cannot change editing file; and Incorrect filename in template file upload
Description
  1. Cannot change file to edit.
    Always go back to File 'startpage.pstpl'
  2. When upload a file to any template, , in template editor, it becomes photo_jpg
Steps To Reproduce

fresh install 1.91RC5 then go to template editor, copy any stock templates, try switching Standard files: always go back to File 'startpage.pstpl'
then try upload any photo, say, photo.jpg, it becomes photo_jpg when upload finished.

TagsNo tags attached.
Attached Files
modifiedsanitize.diff (1,037 bytes)   
--- B:\sanitize.php	2011-03-08 13:50:46.000000000 +0530
+++ C:\xampp\htdocs\limesurvey\classes\core\sanitize.php	2011-04-06 19:34:08.132812500 +0530
@@ -103,10 +103,12 @@
     $strip = array("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "[", "{", "]",
                    "}", "\\", "|", ";", ":", "\"", "'", "‘", "’", "“", "”", "–", "—",
                    "—", "–", ",", "<", ".", ">", "/", "?");
-    $clean = trim(str_replace($strip, "_", strip_tags($string)));
+    $lastdot=strrpos($string, ".");
+	$clean = trim(str_replace($strip, "_", strip_tags($string)));
     $clean = preg_replace('/\s+/', "-", $clean);
     $clean = ($alphanumeric) ? preg_replace("/[^a-zA-Z0-9]/", "", $clean) : $clean ;
-    return ($force_lowercase) ?
+	$clean= substr_replace ( $clean , '.' , $lastdot , 1 );
+	return ($force_lowercase) ?
         (function_exists('mb_strtolower')) ?
             mb_strtolower($clean, 'UTF-8') :
             strtolower($clean) :
modifiedsanitize.diff (1,037 bytes)   
finversanitize.diff (1,074 bytes)   
--- B:\sanitize.php	2011-03-08 13:50:46.000000000 +0530
+++ C:\xampp\htdocs\limesurvey\classes\core\sanitize.php	2011-04-07 02:20:44.971679600 +0530
@@ -103,10 +103,14 @@
     $strip = array("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "[", "{", "]",
                    "}", "\\", "|", ";", ":", "\"", "'", "&#8216;", "&#8217;", "&#8220;", "&#8221;", "&#8211;", "&#8212;",
                    "—", "–", ",", "<", ".", ">", "/", "?");
-    $clean = trim(str_replace($strip, "_", strip_tags($string)));
+    $lastdot=strrpos($string, ".");
+	$clean = trim(str_replace($strip, "_", strip_tags($string)));
     $clean = preg_replace('/\s+/', "-", $clean);
     $clean = ($alphanumeric) ? preg_replace("/[^a-zA-Z0-9]/", "", $clean) : $clean ;
-    return ($force_lowercase) ?
+	if ($lastdotpos !== false) {
+	$clean= substr_replace ( $clean , '.' , $lastdot , 1 );
+	}
+	return ($force_lowercase) ?
         (function_exists('mb_strtolower')) ?
             mb_strtolower($clean, 'UTF-8') :
             strtolower($clean) :
finversanitize.diff (1,074 bytes)   
Bug heat18
Complete LimeSurvey version number (& build)9872
I will donate to the project if issue is resolvedNo
Browser
Database type & versionMySQL
Server OS (if known)Debian 2.6.26-25lenny1
Webserver software & version (if known)Nginx
PHP Version5

Users monitoring this issue

dodev

Activities

user13064

2011-03-31 03:10

  ~14622

Please check it and give feedback if there is any problem.

c_schmitz

c_schmitz

2011-04-04 13:44

administrator   ~14652

murarivivek, that patch is bogus. With the suggested change all invalid characters are replaced with dots but all invalid chars shoudl be replaced with an underscore. Please submit an new patch.

dodev

dodev

2011-04-05 17:48

reporter   ~14678

Well, there was a '.' in the forbidden symbols. Removing it solves the problem :)

user13064

2011-04-05 23:48

  ~14680

Last edited: 2011-04-05 23:48

@dodev yes, that seems to solve the problem

DenisChenu

DenisChenu

2011-04-06 15:13

developer   ~14697

Hello,

You need to remove all dot (.) in the filename except the last one for extension.

For extension, you can remove all non alphanumeric carater, or use the same condition of the filename if you want.

With this patch you can have a file...............name.exte....sio....n

user13064

2011-04-06 16:14

  ~14699

this first takes note of position of last dot in the string. After replacing all not allowed chars, it changes the _ at last dot position to dot again.

Hope this solves the issue

DenisChenu

DenisChenu

2011-04-06 17:40

developer   ~14700

And if lastdot == -1 ?

user13064

2011-04-06 22:52

  ~14709

I made changes such that if lastdot== -1 it will do nothing and leave the filename as before!

DenisChenu

DenisChenu

2011-04-07 10:13

developer   ~14719

Assign it again to Carsten for reviewing :)

user13073

2011-04-12 10:37

  ~14790

Thanks!
Problem #2 fixed, but how about #1 the error of changing editing template file?
Looks like someone else also posted the same problem in forum: http://www.limesurvey.org/en/forum/installation-a-update-issues/59255-problems-editing-with-template-editor

c_schmitz

c_schmitz

2011-04-12 13:33

administrator   ~14795

Last edited: 2011-04-12 13:38

Can't reproduce #1. Works just fine here. Maybe a permission problem in your template folder? Check the permissions on /upload/templates and subfolders/files

user13073

2011-04-13 04:51

  ~14804

Same problem persists even after tried "chmod -R 777 upload/", it also happens on windows server.
Can copy template and change editing Screen, but cannot change editing template file, always go back to startpage.pstpl, plus when try to save changes to startpage.pstpl, got "Invalid template filename" error.

magiclko

magiclko

2011-04-13 16:19

reporter   ~14809

I can't reproduce it either(on windows server)!

c_schmitz

c_schmitz

2011-04-13 16:29

administrator   ~14810

Check your global settings and see if you have set a valid template as default.

ftrifoglio

ftrifoglio

2011-04-14 20:31

reporter   ~14816

I get the same on 1.91RC6.
In the template editor

I can
rename, delete, import, export, copy a template
browse the templates (default, basic, ...)
browse the screens (welcome page, question page, ...)

I cannot
browse and edit .pstpl files
browse and edit .css .js files

c_schmitz

c_schmitz

2011-04-16 16:48

administrator   ~14826

yong, did you check your global settings as requested?

user13515

2011-04-18 18:16

  ~14841

Last edited: 2011-04-18 21:09

same problem here. I can copy each default/basic-template but cannot edit them. The navigation on the left (welcome etc. and the *.css-files) always "jumps back" to startpage.pstl.

My Global Settings say "default" as default-template. I am on RC6. Windows Server 2003. In the log-file of limesurvey nothing related appears. In script-console (new stable release of chrome and firefox) no errors appear.

I did the upgrade from 1.90 to RC6, because of issues with conditional questions.

user13515

2011-04-18 21:10

  ~14842

Last edited: 2011-04-18 21:34

oh and when I try to save the current pstpl-file - which is startpage.pstpl - I get an error: Invalid template filename

Update: I've tested something (I added a testoutput "echo "$editfile";" and found out, that the filename, which is tried to be saved startpage_pstpl instead of startpage.pstpl.

Probably this line "if (!isset($editfile)) {$editfile = sanitize_filename(returnglobal('editfile'));}" contains an error? (see template.php)

user13073

2011-04-26 09:56

  ~14862

Sorry, Schmitz. I was not posting feedback earlier.
I did check my global settings and do have set a valid template as default.
Looks like Landv0gt might have caught the problem, problem with sanitize_filename function, similar to the file upload problem. I'll try to see if the same patch fix the problem #1 too.

c_schmitz

c_schmitz

2011-04-27 18:19

administrator   ~14865

seriously yong, I assumed you had tested that. Please check and report back. Thank you!

user13073

2011-04-28 05:22

  ~14868

Confirming the patch fixed both problem #1 and #2.
Thanks everyone.

Issue History

Date Modified Username Field Change
2011-03-29 11:41 user13073 New Issue
2011-03-29 20:03 c_schmitz Assigned To => c_schmitz
2011-03-29 20:03 c_schmitz Status new => assigned
2011-03-29 20:03 c_schmitz Summary Template editor malfunction: Cannot change editing file; and Incorrect filename in template file upload => GSOC: Template editor malfunction: Cannot change editing file; and Incorrect filename in template file upload
2011-03-31 02:26 user13064 Issue Monitored: user13064
2011-03-31 03:07 user13064 File Added: sanitize.diff
2011-03-31 03:10 user13064 Note Added: 14622
2011-04-04 13:44 c_schmitz Note Added: 14652
2011-04-04 13:44 c_schmitz Status assigned => feedback
2011-04-05 17:47 dodev File Added: fix_santize.diff
2011-04-05 17:48 dodev Note Added: 14678
2011-04-05 18:47 dodev Issue Monitored: dodev
2011-04-05 23:48 user13064 Note Added: 14680
2011-04-05 23:48 user13064 Note Edited: 14680
2011-04-06 15:11 DenisChenu Assigned To c_schmitz => DenisChenu
2011-04-06 15:11 DenisChenu Status feedback => assigned
2011-04-06 15:13 DenisChenu Note Added: 14697
2011-04-06 16:11 user13064 File Added: modifiedsanitize.diff
2011-04-06 16:14 user13064 Note Added: 14699
2011-04-06 17:40 DenisChenu Note Added: 14700
2011-04-06 22:52 user13064 Note Added: 14709
2011-04-06 22:52 user13064 File Added: finversanitize.diff
2011-04-07 10:12 DenisChenu Assigned To DenisChenu => c_schmitz
2011-04-07 10:13 DenisChenu Note Added: 14719
2011-04-11 13:44 c_schmitz File Deleted: sanitize.diff
2011-04-11 13:44 c_schmitz File Deleted: fix_santize.diff
2011-04-11 13:54 c_schmitz Status assigned => resolved
2011-04-11 13:54 c_schmitz Fixed in Version => 1.91
2011-04-11 13:54 c_schmitz Resolution open => fixed
2011-04-12 10:37 user13073 Note Added: 14790
2011-04-12 10:37 user13073 Status resolved => feedback
2011-04-12 10:37 user13073 Resolution fixed => reopened
2011-04-12 13:33 c_schmitz Note Added: 14795
2011-04-12 13:38 c_schmitz Note Edited: 14795
2011-04-13 04:51 user13073 Note Added: 14804
2011-04-13 04:51 user13073 Status feedback => assigned
2011-04-13 16:19 magiclko Note Added: 14809
2011-04-13 16:29 c_schmitz Note Added: 14810
2011-04-14 20:31 ftrifoglio Note Added: 14816
2011-04-16 16:48 c_schmitz Note Added: 14826
2011-04-16 16:48 c_schmitz Status assigned => feedback
2011-04-18 18:16 user13515 Note Added: 14841
2011-04-18 21:09 user13515 Note Edited: 14841
2011-04-18 21:10 user13515 Note Added: 14842
2011-04-18 21:25 user13515 Note Edited: 14842
2011-04-18 21:32 user13515 Note Edited: 14842
2011-04-18 21:34 user13515 Note Edited: 14842
2011-04-26 09:56 user13073 Note Added: 14862
2011-04-26 09:56 user13073 Status feedback => assigned
2011-04-27 18:19 c_schmitz Note Added: 14865
2011-04-27 18:19 c_schmitz Status assigned => resolved
2011-04-27 18:19 c_schmitz Resolution reopened => fixed
2011-04-28 05:22 user13073 Note Added: 14868
2011-05-04 19:31 c_schmitz Status resolved => closed
2015-12-11 14:40 c_schmitz Category Templates => Theme editor
2021-08-04 06:10 guest Bug heat 16 => 18