Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Mar 30, 2020
2 parents 3a04e97 + e83e09d commit f439a2e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion application/controllers/RegisterController.php
Expand Up @@ -174,7 +174,7 @@ public function getRegisterErrors($iSurveyId)
//Check that the email is a valid style address
if ($aFieldValue['sEmail'] == "") {
$this->aRegisterErrors[] = gT("You must enter a valid email. Please try again.");
} elseif (!validateEmailAddress($aFieldValue['sEmail'])) {
} elseif (!validateEmailAddress(trim($aFieldValue['sEmail']))) {
$this->aRegisterErrors[] = gT("The email you used is not valid. Please try again.");
}
//Check and validate attribute
Expand Down
3 changes: 2 additions & 1 deletion application/controllers/admin/tokens.php
Expand Up @@ -2400,7 +2400,8 @@ public function bouncesettings($iSurveyId)

$aData['sidemenu']['state'] = false;
$aData['title_bar']['title'] = $survey->currentLanguageSettings->surveyls_title." (".gT("ID").":".$iSurveyId.")";

$aData['topBar']['showSaveButton'] = true;

$this->_renderWrappedTemplate('token', array('bounce'), $aData);
}

Expand Down
6 changes: 4 additions & 2 deletions application/core/LSYii_Application.php
Expand Up @@ -415,8 +415,8 @@ public function onException($event)
}

/**
* Check if a file is inside a specific directory
* @var string $dirPath complete directory path
* Check if a file (with a full path) is inside a specific directory
* @var string $filePath complete file path
* @var string $baseDir the directory where it must be, default to upload dir
* @var boolean|null $throwException if security issue
* Throw Exception
Expand All @@ -431,6 +431,8 @@ public function is_file($filePath,$baseDir = null,$throwException = null)
$throwException = boolval($this->getConfig('debug'));
}
$realFilePath = realpath($filePath);
$baseDir = realpath($baseDir);

if(!is_file($realFilePath)) {
/* Not existing file */
Yii::log("Try to read invalid file ".$filePath, 'warning', 'application.security.files.is_file');
Expand Down
24 changes: 20 additions & 4 deletions assets/packages/limesurvey/survey.js
Expand Up @@ -213,20 +213,35 @@ function activateLanguageChanger(){
}
});
/* Language changer dropdown */
/* Don't activate change when using key up / key down */
$('.form-change-lang [name="lang"]').on('keypress keydown keyup', function(event) {
var code = event.keyCode || event.which;
/* packaje name : limesurvey */
$(this).data("limesurvey-lastkey",code);
});
$('.form-change-lang [name="lang"]').on('click', function(event) {
/* didn't work with chrome , chrom bug : onclick are an intrinsic event see https://www.w3.org/TR/html401/interact/forms.html#h-17.6 */
/* Happen rarely (keyboard + mouse + still have the button */
$(this).data("limesurvey-lastkey",null);
});
$('.form-change-lang [name="lang"]').on('change', function(event) {
if( $(this).data("limesurvey-lastkey") == 38 || $(this).data("lastkey") == 40) {
/* Last key is up or down : disable auto submit mantis #16024 */
return;
}
var closestForm = $(this).closest('form');
var newLang = $(this).val();
if (!closestForm.length) {
/* we are not in a forum, can not submit directly */
/* we are not in a form, can not submit directly */
// Remind user can put language changer everywhere, not only in home page, but for example in clear all page etc … in form or not etc ...
if (limesurveyForm.length == 1) {
/* The limesurvey form exist in document, move select and button inside and click */
applyChangeAndSubmit(newLang);
// TODO: Check all code below. When does it happen?
// Answer : remind user can put language changer everywhere, not only in home page, but for example in clear all page etc …
} else {
// If there are no form : we can't use it */
if($(this).parent().data('targeturl')){
/* If we have a target url : just move location to this url with lang set */
/* targeturl was used for preview gropup and question in 2.6lts : check if still used/usable */
var target=$(this).parent().data('targeturl');
/* adding lang in get param manually */
if(target.indexOf("?") >=0){
Expand All @@ -239,6 +254,7 @@ function activateLanguageChanger(){
return false;
}else{
/* No form, not targeturl : just see what happen */
/* This must not happen : issue in theme */
$("<form>", {
"class":'ls-js-hidden',
"html": '<input type="hidden" name="lang" value="' + newLang + '" />',
Expand All @@ -250,7 +266,7 @@ function activateLanguageChanger(){
}
}else{
/* we are inside a form : just submit : but remove other lang input if exist : be sure it's this one send */
$(this).closest('form').find("[name='lang']").not($(this).parent()).remove();
$(this).closest('form').find("[name='lang']").not(this).remove();
$(this).closest('.form-change-lang').find(':submit').click();
}
});
Expand Down

0 comments on commit f439a2e

Please sign in to comment.