diff --git a/README.md b/README.md index 1fa2716..3ed2fbe 100644 --- a/README.md +++ b/README.md @@ -461,6 +461,30 @@ Measures currently in place: outside a small allowlist of comment/doc links (so googleapis.com, gstatic.com, fonts.google.com, cdnfonts.com, jsdelivr.net, … can never ship). +- **Option-value sanitization at emission (S1)** — LimeSurvey renders theme twig + with **autoescape OFF**, so theme option values (stored JSON, settable via + API/DB/import by anyone with theme-options edit rights) are untrusted input on + the **public** survey pages. `views/subviews/security_macros.twig` provides + validators — `color()` (hex or plain keyword), `length()` (`16px`/`1.2rem`/`90%`), + `keyword()` (enum words), `fontslug()` (`font-` class tokens), + `pxnum()` (unitless px), `iconcode()` (check-icon codepoint) — applied at every + emission point: the `` or `x" onload="…` is neutralized and falls back + to the configured default; legitimate picker/enum/slug values pass through + unchanged. **Usability impact: none for legitimate values.** +- **Escaped imagefile options (S2)** — `options/options.twig` builds the imagefile + ``/` per image group #} {% set imageOptions = '' %} {% set imgGroup = '' %} +{# S2 (SECURITY_REVIEW_20261129.md): image names can also arrive via FTP/deploy/git + (NOT sanitized like uploader names) — every part below is escaped at build time; + the assembled string is output with |raw further down. #} {% for image in templateConfiguration.imageFileList %} {% if image.group != imgGroup %} {% if imgGroup != '' %}{% set imageOptions = imageOptions ~ '' %}{% endif %} - {% set imageOptions = imageOptions ~ '' %} + {% set imageOptions = imageOptions ~ '' %} {% set imgGroup = image.group %} {% endif %} - {% set imageOptions = imageOptions ~ '' %} + {% set imageOptions = imageOptions ~ '' %} {% endfor %} {% if imgGroup != '' %}{% set imageOptions = imageOptions ~ '' %}{% endif %} diff --git a/views/layout_global.twig b/views/layout_global.twig new file mode 100644 index 0000000..03861d5 --- /dev/null +++ b/views/layout_global.twig @@ -0,0 +1,160 @@ +{# + LimeSurvey + Copyright (C) 2007-2026 The LimeSurvey Project Team + All rights reserved. + License: GNU/GPL License v2 or later, see LICENSE.php + LimeSurvey is free software. This version may have been modified pursuant + to the GNU General Public License, and as distributed it includes or + is derivative of works licensed under the GNU General Public License or + other free or open source software licenses. + See COPYRIGHT.php for copyright notices and details. + + (¯`·._.·(¯`·._.· Global Layout ·._.·´¯)·._.·´¯) + + This is the global layout that will be used to displayed most pages (less the error page) + If you're creating your own template, remember there is no obligation to respect the current file flow of this template. + This is different from the old LimeSurvey template engine, where you had to provide every one of the pstpl files. + Here, you must have a file called main_layout.twig (called from SurveyRuntimeHelper::run() ). + Other than that, you're free to organize your files and inclusions as you want. + + + + (¯`·._.·(¯`·._.· Bootstrap ·._.·´¯)·._.·´¯) + + LimeSurvey uses Bootstrap. + See: https://getbootstrap.com + + This template is an instance of Bootswatch Theme Flatly. + See: https://bootswatch.com/ + + + + (¯`·._.·(¯`·._.· Twig Engine ·._.·´¯)·._.·´¯) + + The template engine uses Twig. + See: http://twig.sensiolabs.org/ + + The main variable is aSurveyInfo. It's an array containing the main information about the survey. + aSurveyInfo also contains other needed arrays, such as aNavigator, or aQuestionGroups (which contain aQuestions), etc. + + If you want to see what is available in aSurveyInfo, turn debug mode on in application/config.php, and copy the following line to the end of the element below: + {{ dump(aSurveyInfo) }} + + To echo a variable, just insert : {{ variable }} + To translate a string, just insert : {{gT( string )}} + + NOTE: aSurveyInfo should be cleaned to remove the unnecessary data. + + + (¯`·._.·(¯`·._.· Twig Engine: advanced ·._.·´¯)·._.·´¯) + + For security reason, Twig is in a sandBox. + About sandBox, see: http://twig.sensiolabs.org/doc/2.x/api.html#sandbox-extension + + Available functions/Object Methods are defined in internal.php: components => twigRenderer + Eg: + Functions : 'include', 'dump', 'flatEllipsizeText', 'getLanguageData', 'array_flip', 'array_intersect_key', 'registerPublicCssFile', 'getAllQuestionClasses', 'getShowqnumcode', 'intval' + + Methods : + - CHtml::textfield() (and: form, link, emailField, beginForm, endForm, dropDownList,htmlButton) + - Survey::getAllLanguages() + - LSHttpRequest::getParam() + + If you need to add simple functions or static methods, just add them to internal.php. + If you need to add complex process, use application/core/LS_Twig_Extension.php (more help/comments there) + + + NOTE: Feel free to ask for functions, variables, etc, that you feel are missing - https://bugs.limesurvey.org/my_view_page.php +#} + +{# THEME OVERRIDE of vanilla's layout_global.twig: identical, except the S1 + sanitization of the font-{{ }} body class and data-thememode below (see + security_macros.twig). Keep in sync with the parent when vanilla changes. #} + + + + {% block head %} + {# Headers, metadata, etc #} + {{ include('./subviews/header/head.twig') }} + {% endblock %} + {# S1 (SECURITY_REVIEW_20261129.md): this layout is inherited from vanilla — the + body class font- and data-thememode are raw option values there; sanitize + them at emission here (autoescape is OFF in LimeSurvey theme twig). #} + {% import './subviews/security_macros.twig' as sec %} + + + {# Notice if emcache is on or off, used by tests. #} + {% if aSurveyInfo.emcache %} + + {% else %} + + {% endif %} + + {# This used for the pjax system #} + {% block pjaxbegin %} +
+ <###begin###> +
+ {% endblock %} + + {# Ajaxify cannot handle an element that is a direct child of body, so => create simple wrapper section #} +
+ +
+ {% block body %} + + {# Skip link for keyboard users: Only visible when focused #} + + + {# Bootstrap Navigation Bar: the top menu #} + {% block nav_bar %} + {{ include('./subviews/header/nav_bar.twig') }} + {% endblock %} + + {# Top Container: in this template, it contains only #} + {% block progress %} + {{ include('./subviews/header/progress_bar.twig') }} + {% endblock %} + + + {% block content %} + {# + Content depends on the action (survey, questions, register, assessments, submit, etc) + Action are in ./subviews/content/ + #} + {% set sViewContent = './subviews/content/' ~ aSurveyInfo.include_content ~ '.twig' %} + {% include './subviews/content/outerframe.twig' with {'include_content': sViewContent } %} + {% endblock %} + + {# Bootstrap alert modal #} + {{ include('./subviews/messages/bootstrap_alert_modal.twig') }} + + {# Basic ThemeScript options #} + {{ registerScript("BasicThemeScripts", " + if(window.basicThemeScripts === undefined){ + window.basicThemeScripts = new ThemeScripts(); + } + basicThemeScripts.initGlobal(); + ", "POS_END") }} + + {% endblock %} +
+ +
+ {% block footer %} + {{ include('./subviews/footer/footer.twig') }} + {% endblock %} + {% block pjaxend %} +
+ <###end###> +
+ {% endblock %} + + {% block themescripts %} + + {% endblock %} + + + diff --git a/views/layout_survey_list.twig b/views/layout_survey_list.twig index 4c8c4da..11f9b51 100644 --- a/views/layout_survey_list.twig +++ b/views/layout_survey_list.twig @@ -88,11 +88,14 @@ NOTE: Feel free to ask for functions, variables, etc, that you feel are missing +{# S1: sanitize option values at emission (autoescape is OFF) — see security_macros.twig #} +{% import './subviews/security_macros.twig' as sec %} + {# Headers, metadata, etc #} {{ include('./subviews/header/head.twig') }} + class=" {{ aSurveyInfo.class.body }} font-{{ sec.fontslug(aSurveyInfo.options.font|default('inter')) }} lang-{{ aSurveyInfo.languagecode }} {{ aSurveyInfo.surveyformat }} {% if( aSurveyInfo.options.brandlogofile|default('off') not in ['off', '', 'inherit'] and aSurveyInfo.options.brandlogo|default('on') != 'off') %}brand-logo{% endif %}" {{ aSurveyInfo.attr.body }} > {# This used for the pjax system #}
diff --git a/views/subviews/header/custom_header.twig b/views/subviews/header/custom_header.twig index c25cd54..00b26ba 100644 --- a/views/subviews/header/custom_header.twig +++ b/views/subviews/header/custom_header.twig @@ -25,7 +25,14 @@ old 4-way textcolor dropdowns map to color1/color2 as well. #} {% macro cm(mode, custom, opts) -%} {%- set m = mode|default('') -%} - {{- m matches '/^#[0-9a-fA-F]{3,8}$/' ? m : (m == 'color1' or m == 'primary' ? opts.primarycolor|default('') : (m == 'color2' or m == 'secondary' ? opts.secondarycolor|default('') : (m == 'color3' ? opts.tertiarycolor|default('') : (m == 'defaultbackgroundcolor' ? opts.defaultbackgroundcolor|default('') : (m == 'other' ? custom|default('') : opts.fontcolor|default('')))))) -}} + {%- set r = m matches '/^#[0-9a-fA-F]{3,8}$/' ? m : (m == 'color1' or m == 'primary' ? opts.primarycolor|default('') : (m == 'color2' or m == 'secondary' ? opts.secondarycolor|default('') : (m == 'color3' ? opts.tertiarycolor|default('') : (m == 'defaultbackgroundcolor' ? opts.defaultbackgroundcolor|default('') : (m == 'other' ? custom|default('') : opts.fontcolor|default('')))))) -%} + {#- S1 (SECURITY_REVIEW_20261129.md): validate the RESOLVED value as well — it can + come from another raw option (primarycolor, *custom, legacy stored value). + Hex or plain color keyword only; anything else resolves to '' (the CSS + declaration is then dropped and the stylesheet default applies). Same + validation as sec.color() in security_macros.twig (twig macros cannot call + imported macros, so it is inlined here). -#} + {{- (r matches '/^#[0-9a-fA-F]{3,8}$/' or r matches '/^[a-zA-Z]{3,20}$/') ? r : '' -}} {%- endmacro %} {# Row 191 / row 178 plan P6: like cm(), but for BACKGROUND choosers — mode "default" means "no override" (empty string), so the Bootstrap button default @@ -33,20 +40,25 @@ way as cm(). Used for the per-button background colors of the navigator. #} {% macro cmbg(mode, custom, opts) -%} {%- set m = mode|default('') -%} - {{- m matches '/^#[0-9a-fA-F]{3,8}$/' ? m : (m == 'color1' or m == 'primary' ? opts.primarycolor|default('') : (m == 'color2' or m == 'secondary' ? opts.secondarycolor|default('') : (m == 'color3' ? opts.tertiarycolor|default('') : (m == 'defaultbackgroundcolor' ? opts.defaultbackgroundcolor|default('') : (m == 'other' ? custom|default('') : ''))))) -}} + {%- set r = m matches '/^#[0-9a-fA-F]{3,8}$/' ? m : (m == 'color1' or m == 'primary' ? opts.primarycolor|default('') : (m == 'color2' or m == 'secondary' ? opts.secondarycolor|default('') : (m == 'color3' ? opts.tertiarycolor|default('') : (m == 'defaultbackgroundcolor' ? opts.defaultbackgroundcolor|default('') : (m == 'other' ? custom|default('') : ''))))) -%} + {#- S1: same resolved-value validation as cm() above. -#} + {{- (r matches '/^#[0-9a-fA-F]{3,8}$/' or r matches '/^[a-zA-Z]{3,20}$/') ? r : '' -}} {%- endmacro %} {% import _self as cmm %} +{# S1 (SECURITY_REVIEW_20261129.md): sanitizers for option values emitted raw below + (autoescape is OFF in LimeSurvey theme twig). #} +{% import './subviews/security_macros.twig' as sec %} `, quotes, + braces, semicolons, parens etc. can never reach the output. + + Import in a view with: {% import './subviews/security_macros.twig' as sec %} + ('./' resolves against the theme's views/ root, like every other include). + + NOTE: twig macros only see globals + their own arguments, so macros defined + in custom_header.twig itself (cm/cmbg) cannot call sec.* — they inline the + same validation instead. +#} + +{# A CSS color value: #rgb/#rrggbb/#rrggbbaa hex, or a plain color keyword + (transparent, lightyellow, currentColor, ...). Anything else -> fallback. #} +{% macro color(value, fallback = '') -%} + {%- set v = value|default('') -%} + {{- (v matches '/^#[0-9a-fA-F]{3,8}$/' or v matches '/^[a-zA-Z]{3,20}$/') ? v : fallback|default('') -}} +{%- endmacro %} + +{# A CSS length/percentage: 16px, 1.2rem, 2em, 90%, ... #} +{% macro length(value, fallback = '') -%} + {%- set v = value|default('') -%} + {{- v matches '/^[0-9]+([.][0-9]+)?(px|rem|em|%)$/' ? v : fallback|default('') -}} +{%- endmacro %} + +{# A single CSS keyword/enum: solid, dashed, italic, fixed, tile, cover, ... #} +{% macro keyword(value, fallback = '') -%} + {%- set v = value|default('') -%} + {{- v matches '/^[a-zA-Z-]{1,30}$/' ? v : fallback|default('') -}} +{%- endmacro %} + +{# A font-select slug, emitted as the class token font- inside a class + attribute: [a-zA-Z0-9_-] only; invalid values become "base" (no override). #} +{% macro fontslug(value) -%} + {%- set v = value|default('') -%} + {{- v matches '/^[a-zA-Z0-9_-]{1,40}$/' ? v : 'base' -}} +{%- endmacro %} + +{# A unitless px number (the "px" is appended in the template): digits only. #} +{% macro pxnum(value, fallback = '0') -%} + {%- set v = value|default('') -%} + {{- v matches '/^[0-9]{1,4}$/' ? v : fallback|default('0') -}} +{%- endmacro %} + +{# A check-icon unicode codepoint for the CSS content property (e.g. EB7A): + hex digits only; anything else -> fallback. #} +{% macro iconcode(value, fallback = 'EB7A') -%} + {%- set v = value|default('') -%} + {{- v matches '/^[0-9a-fA-F]{1,6}$/' ? v : fallback|default('EB7A') -}} +{%- endmacro %} diff --git a/views/subviews/survey/group_subviews/group_desc.twig b/views/subviews/survey/group_subviews/group_desc.twig index 046e1d3..48374d1 100644 --- a/views/subviews/survey/group_subviews/group_desc.twig +++ b/views/subviews/survey/group_subviews/group_desc.twig @@ -21,6 +21,8 @@ {# THEME ADDITION: font for the group description (config.xml option "groupdescriptionfont", type fontselect). "base" = same as the base font: no extra class, inherits body font. #} +{# S1: sanitize option values at emission (autoescape is OFF) — see security_macros.twig #} +{% import './subviews/security_macros.twig' as sec %} {% set sGroupDescFont = aSurveyInfo.options.groupdescriptionfont|default('base') %} {# Row 157: group description color is a color-chooser now (mode dropdown default|defaultbackgroundcolor|color1|color2|color3|other, like navbarfontcolor @@ -32,11 +34,12 @@ style on the element below. #} {% set sGroupDescTextColorMode = aSurveyInfo.options.groupdescriptiontextcolor|default('default') %} {% set sGroupDescTextColor = sGroupDescTextColorMode matches '/^#[0-9a-fA-F]{3,8}$/' ? sGroupDescTextColorMode : ((sGroupDescTextColorMode == 'color1' or sGroupDescTextColorMode == 'primary') ? aSurveyInfo.options.primarycolor|default('') : ((sGroupDescTextColorMode == 'color2' or sGroupDescTextColorMode == 'secondary') ? aSurveyInfo.options.secondarycolor|default('') : (sGroupDescTextColorMode == 'color3' ? aSurveyInfo.options.tertiarycolor|default('') : (sGroupDescTextColorMode == 'defaultbackgroundcolor' ? aSurveyInfo.options.defaultbackgroundcolor|default('') : (sGroupDescTextColorMode == 'other' ? aSurveyInfo.options.groupdescriptiontextcolorcustom|default('') : aSurveyInfo.options.fontcolor|default('')))))) %} +{% set sGroupDescTextColor = sec.color(sGroupDescTextColor, '') %} {% if aGroup.showgroupinfo == 'D' or aGroup.showgroupinfo == 'B' %} {% if aGroup.description != '' %} -
+
{{ processString(aGroup.description) }}
diff --git a/views/subviews/survey/group_subviews/group_name.twig b/views/subviews/survey/group_subviews/group_name.twig index 72279f5..c6b72fd 100644 --- a/views/subviews/survey/group_subviews/group_name.twig +++ b/views/subviews/survey/group_subviews/group_name.twig @@ -21,6 +21,8 @@ {# THEME ADDITION: font for the group title (config.xml option "grouptitlefont", type fontselect). "base" = same as the base font: no extra class, inherits body font. #} +{# S1: sanitize option values at emission (autoescape is OFF) — see security_macros.twig #} +{% import './subviews/security_macros.twig' as sec %} {% set sGroupTitleFont = aSurveyInfo.options.grouptitlefont|default('base') %} {# Row 157: group title color is a color-chooser now (mode dropdown default|defaultbackgroundcolor|color1|color2|color3|other, like navbarfontcolor @@ -32,8 +34,9 @@ style on the element below. #} {% set sGroupTitleTextColorMode = aSurveyInfo.options.grouptitletextcolor|default('default') %} {% set sGroupTitleTextColor = sGroupTitleTextColorMode matches '/^#[0-9a-fA-F]{3,8}$/' ? sGroupTitleTextColorMode : ((sGroupTitleTextColorMode == 'color1' or sGroupTitleTextColorMode == 'primary') ? aSurveyInfo.options.primarycolor|default('') : ((sGroupTitleTextColorMode == 'color2' or sGroupTitleTextColorMode == 'secondary') ? aSurveyInfo.options.secondarycolor|default('') : (sGroupTitleTextColorMode == 'color3' ? aSurveyInfo.options.tertiarycolor|default('') : (sGroupTitleTextColorMode == 'defaultbackgroundcolor' ? aSurveyInfo.options.defaultbackgroundcolor|default('') : (sGroupTitleTextColorMode == 'other' ? aSurveyInfo.options.grouptitletextcolorcustom|default('') : aSurveyInfo.options.fontcolor|default('')))))) %} +{% set sGroupTitleTextColor = sec.color(sGroupTitleTextColor, '') %} {% if aGroup.showgroupinfo == 'N' or aGroup.showgroupinfo == 'B' %} -
+
{{ processString(aGroup.name, false, 3, {'GID': aGroup.gid}) }}
{% endif %} diff --git a/views/subviews/survey/question_subviews/answers.twig b/views/subviews/survey/question_subviews/answers.twig index 5c938e8..6c4cced 100644 --- a/views/subviews/survey/question_subviews/answers.twig +++ b/views/subviews/survey/question_subviews/answers.twig @@ -21,6 +21,8 @@ {# THEME ADDITION: font for the answers (config.xml option "answersfont", type fontselect). "base" = same as the base font: no extra class, inherits body font. #} +{# S1: sanitize option values at emission (autoescape is OFF) — see security_macros.twig #} +{% import './subviews/security_macros.twig' as sec %} {% set sAnswersFont = aSurveyInfo.options.answersfont|default('base') %} {# Prompt U: per-element text color — mode default -> fontcolor, primary -> primarycolor, secondary -> secondarycolor, other -> answerstextcolorcustom. @@ -29,9 +31,10 @@ {# row 184 / plan P3: 6-way color-chooser scheme (default|defaultbackgroundcolor|color1|color2|color3|other) + legacy modes primary/secondary and raw hex passthrough #} {% set oA = aSurveyInfo.options %} {% set sAnswersTextColor = sAnswersTextColorMode matches '/^#[0-9a-fA-F]{3,8}$/' ? sAnswersTextColorMode : (sAnswersTextColorMode == 'color1' or sAnswersTextColorMode == 'primary' ? oA.primarycolor|default('') : (sAnswersTextColorMode == 'color2' or sAnswersTextColorMode == 'secondary' ? oA.secondarycolor|default('') : (sAnswersTextColorMode == 'color3' ? oA.tertiarycolor|default('') : (sAnswersTextColorMode == 'defaultbackgroundcolor' ? oA.defaultbackgroundcolor|default('') : (sAnswersTextColorMode == 'other' ? oA.answerstextcolorcustom|default('') : oA.fontcolor|default('')))))) %} +{% set sAnswersTextColor = sec.color(sAnswersTextColor, '') %} -
+
{# NOTE: If you want to customize the question rendering, use a question theme #} {{ aQuestion.answer | raw }}
diff --git a/views/subviews/survey/question_subviews/question_text_container.twig b/views/subviews/survey/question_subviews/question_text_container.twig index a61accd..2fdd1bd 100644 --- a/views/subviews/survey/question_subviews/question_text_container.twig +++ b/views/subviews/survey/question_subviews/question_text_container.twig @@ -22,6 +22,8 @@ {# THEME ADDITION: font for the question title block (config.xml option "questiontitlefont", type fontselect). "base" = same as the base font: no extra class, the element inherits the body font. #} +{# S1: sanitize option values at emission (autoescape is OFF) — see security_macros.twig #} +{% import './subviews/security_macros.twig' as sec %} {% set sQuestionTitleFont = aSurveyInfo.options.questiontitlefont|default('base') %} {# Prompt U / row 180 plan P2: per-element text color — now the 6-way color-chooser scheme (default|defaultbackgroundcolor|color1|color2|color3|other) with @@ -33,8 +35,9 @@ {% set sQuestionTitleTextColorMode = aSurveyInfo.options.questiontitletextcolor is defined ? aSurveyInfo.options.questiontitletextcolor : '' %} {% set oQ = aSurveyInfo.options %} {% set sQuestionTitleTextColor = sQuestionTitleTextColorMode == '' ? '' : (sQuestionTitleTextColorMode matches '/^#[0-9a-fA-F]{3,8}$/' ? sQuestionTitleTextColorMode : (sQuestionTitleTextColorMode == 'color1' or sQuestionTitleTextColorMode == 'primary' ? oQ.primarycolor|default('') : (sQuestionTitleTextColorMode == 'color2' or sQuestionTitleTextColorMode == 'secondary' ? oQ.secondarycolor|default('') : (sQuestionTitleTextColorMode == 'color3' ? oQ.tertiarycolor|default('') : (sQuestionTitleTextColorMode == 'defaultbackgroundcolor' ? oQ.defaultbackgroundcolor|default('') : (sQuestionTitleTextColorMode == 'other' ? oQ.questiontitletextcolorcustom|default('') : oQ.fontcolor|default(''))))))) %} +{% set sQuestionTitleTextColor = sec.color(sQuestionTitleTextColor, '') %} -
+
{{ include('./subviews/survey/question_subviews/question_text_content.twig') }}
diff --git a/views/subviews/survey/question_subviews/survey_question_help.twig b/views/subviews/survey/question_subviews/survey_question_help.twig index 70835b0..38b6a7b 100644 --- a/views/subviews/survey/question_subviews/survey_question_help.twig +++ b/views/subviews/survey/question_subviews/survey_question_help.twig @@ -22,6 +22,8 @@ Row 195: the dedicated help font (config.xml option "questionhelpfont", type fontselect) wins when set to something other than "base"; otherwise the answers font is used as before. #} +{# S1: sanitize option values at emission (autoescape is OFF) — see security_macros.twig #} +{% import './subviews/security_macros.twig' as sec %} {% set sHelpFont = aSurveyInfo.options.questionhelpfont|default('') %} {% set sAnswersFont = aSurveyInfo.options.answersfont|default('base') %} {% set sUsedFont = (sHelpFont != '' and sHelpFont != 'base') ? sHelpFont : sAnswersFont %} @@ -32,9 +34,10 @@ {# row 184 / plan P3: 6-way color-chooser scheme (default|defaultbackgroundcolor|color1|color2|color3|other) + legacy modes primary/secondary and raw hex passthrough #} {% set oA = aSurveyInfo.options %} {% set sAnswersTextColor = sAnswersTextColorMode matches '/^#[0-9a-fA-F]{3,8}$/' ? sAnswersTextColorMode : (sAnswersTextColorMode == 'color1' or sAnswersTextColorMode == 'primary' ? oA.primarycolor|default('') : (sAnswersTextColorMode == 'color2' or sAnswersTextColorMode == 'secondary' ? oA.secondarycolor|default('') : (sAnswersTextColorMode == 'color3' ? oA.tertiarycolor|default('') : (sAnswersTextColorMode == 'defaultbackgroundcolor' ? oA.defaultbackgroundcolor|default('') : (sAnswersTextColorMode == 'other' ? oA.answerstextcolorcustom|default('') : oA.fontcolor|default('')))))) %} +{% set sAnswersTextColor = sec.color(sAnswersTextColor, '') %} -
+
{% if aQuestion.help.show %}
{{ aQuestion.help.text | raw }} diff --git a/views/subviews/survey/question_subviews/valid_message_and_help.twig b/views/subviews/survey/question_subviews/valid_message_and_help.twig index ffc7d91..2fefd40 100644 --- a/views/subviews/survey/question_subviews/valid_message_and_help.twig +++ b/views/subviews/survey/question_subviews/valid_message_and_help.twig @@ -22,6 +22,8 @@ {# THEME ADDITION: validation messages / mandatory hints use the answers font (config.xml option "answersfont", type fontselect). "base" = same as the base font: no extra class, inherits body font. #} +{# S1: sanitize option values at emission (autoescape is OFF) — see security_macros.twig #} +{% import './subviews/security_macros.twig' as sec %} {% set sAnswersFont = aSurveyInfo.options.answersfont|default('base') %} {# Prompt U: per-element text color — mode default -> fontcolor, primary -> primarycolor, secondary -> secondarycolor, other -> answerstextcolorcustom. @@ -30,9 +32,10 @@ {# row 184 / plan P3: 6-way color-chooser scheme (default|defaultbackgroundcolor|color1|color2|color3|other) + legacy modes primary/secondary and raw hex passthrough #} {% set oA = aSurveyInfo.options %} {% set sAnswersTextColor = sAnswersTextColorMode matches '/^#[0-9a-fA-F]{3,8}$/' ? sAnswersTextColorMode : (sAnswersTextColorMode == 'color1' or sAnswersTextColorMode == 'primary' ? oA.primarycolor|default('') : (sAnswersTextColorMode == 'color2' or sAnswersTextColorMode == 'secondary' ? oA.secondarycolor|default('') : (sAnswersTextColorMode == 'color3' ? oA.tertiarycolor|default('') : (sAnswersTextColorMode == 'defaultbackgroundcolor' ? oA.defaultbackgroundcolor|default('') : (sAnswersTextColorMode == 'other' ? oA.answerstextcolorcustom|default('') : oA.fontcolor|default('')))))) %} +{% set sAnswersTextColor = sec.color(sAnswersTextColor, '') %} -
+
{{ aQuestion.valid_message | raw }} {# The validation message, eg: "Only numbers may be entered in this field.". This text is inside EM Helper, and can be changed by creating a translation file #} {{ aQuestion.man_message | raw }} {# The question mandatory error message: "This question is mandatory!". This text is inside EM Helper, and can be changed by creating a translation file #} {{ aQuestion.file_valid_message | raw }} {# Used only for file upload question type... TODO: check if we can remove it and use valid_message for file upload question type too #}