View Issue Details

This bug affects 1 person(s).
 10
IDProjectCategoryView StatusLast Update
05401Bug reportsSurvey takingpublic2012-03-14 21:08
Reporteruser15287Assigned Totpartner  
PrioritylowSeverityminor 
Status closedResolutionfixed 
Product Version1.91+ 
Summary05401: large and huge free text max characters not respected on mouse-based paste events
Description

Performing a mouse-based paste event, such as a "right mouse-click -> paste" (mouse contextual menu) or selecting the Edit->Paste menu item with the mouse doesn't properly truncate the free text to the set maximum characters attribute set for the question. Key-based paste events, such as CTRL-V is respected and text is truncated.

This appears to be the case in the most recent stable builds of Chrome and Firefox on Mac and Windows.

The short free text maximum characters attribute does appear to correctly respect both mouse and keyboard based events.

Steps To Reproduce
  1. Create a free text question (large or huge) and set the maximum characters attribute to some arbitrary limit.
  2. Select and copy text containing more characters than what is allowed by the maximum characters attribute.
  3. Execute the survey and paste the text into the textarea using just the mouse, either with a right-mouse-click->Paste or selecting Paste from the Edit menu.
  4. submit or save the survey. Browsing survey responses shows the text saved still contains more characters than allowed by the maximum characters attributeI think this can be fixed by changing the longfreetext and hugefreetext "textarea" event attributes calling the "textLimit" function from "onKeyUp" to "onChange" in the qanda.php file
TagsNo tags attached.
Attached Files
05401-00-maxlength-textarea-limit.diff (1,628 bytes)   
### Eclipse Workspace Patch 1.0
#P Limesurvey 1.x trunk stable
Index: qanda.php
===================================================================
--- qanda.php	(revision 10756)
+++ qanda.php	(working copy)
@@ -4966,7 +4966,7 @@
 
     // --> START NEW FEATURE - SAVE
     $answer .= '<textarea class="textarea '.$kpclass.'" name="'.$ia[1].'" id="answer'.$ia[1].'" alt="'.$clang->gT('Answer').'" '
-    .'rows="'.$drows.'" cols="'.$tiwidth.'" onkeyup="textLimit(\'answer'.$ia[1].'\', '.$maxsize.'); '.$checkconditionFunction.'(this.value, this.name, this.type)">';
+    .'rows="'.$drows.'" cols="'.$tiwidth.'" maxlength="'.$maxsize.'" onchange="textLimit(\'answer'.$ia[1].'\', '.$maxsize.');" onkeyup="textLimit(\'answer'.$ia[1].'\', '.$maxsize.'); '.$checkconditionFunction.'(this.value, this.name, this.type)">';
     // --> END NEW FEATURE - SAVE
 
     if ($_SESSION[$ia[1]]) {$answer .= str_replace("\\", "", $_SESSION[$ia[1]]);}
@@ -5056,7 +5056,7 @@
 
     // --> START NEW FEATURE - SAVE
     $answer .= '<textarea class="textarea '.$kpclass.'" name="'.$ia[1].'" id="answer'.$ia[1].'" alt="'.$clang->gT('Answer').'" '
-    .'rows="'.$drows.'" cols="'.$tiwidth.'" onkeyup="textLimit(\'answer'.$ia[1].'\', '.$maxsize.'); '.$checkconditionFunction.'(this.value, this.name, this.type)">';
+    .'rows="'.$drows.'" cols="'.$tiwidth.'" maxlength="'.$maxsize.'" onchange="textLimit(\'answer'.$ia[1].'\', '.$maxsize.');" onkeyup="textLimit(\'answer'.$ia[1].'\', '.$maxsize.'); '.$checkconditionFunction.'(this.value, this.name, this.type)">';
     // --> END NEW FEATURE - SAVE
 
     // <-- END ENHANCEMENT - TEXT INPUT WIDTH
Bug heat10
Complete LimeSurvey version number (& build)10746
I will donate to the project if issue is resolvedNo
Browser
Database type & versionmysql 5.0.77
Server OS (if known)CentoOS 5.4
Webserver software & version (if known)apache 2.2
PHP Version5.1

Users monitoring this issue

There are no users monitoring this issue.

Activities

mot

mot

2011-08-17 19:18

reporter   ~16087

An additional "maxlength" attribute for the "textarea" tag could make the browser limit the input w/o javascript need (Number of Unicode Codepoints, HTML5).

Additionally to make the javascript routine work, the "onchange" and/or "onblur" event needs to be added that at least the text is getting truncated when the focus is lost.

Mazi

Mazi

2011-08-18 16:11

updater   ~16098

Tony, refering to mot's comment, do you think we can easily solve this special pasting method?

user15287

2011-08-18 16:23

  ~16099

I think IE9 still doesn't support the "maxlength" attribute for the "textarea" tag.

tpartner

tpartner

2011-09-05 18:28

partner   ~16230

IE may not support maxlength for textareas but it is a valid attribute in HTML5 so I added it.

Also added the onchange event and moved function textLimit() to survey_runtime.js.

Thanks everyone for the input.

Fixed in revision 10949.

c_schmitz

c_schmitz

2011-09-07 09:16

administrator   ~16237

New version released

Related Changesets

LimeSurvey: Yii 55824b28

2011-09-05 09:21:46

tpartner

Details Diff
Fixed issue 05401: large and huge free text max characters not respected on mouse-based paste events
Dev Added onchange event to textareas to fire textLimit()
Dev Moved function textLimit() to survey_runtime.js

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@10948 b72ed6b6-b9f8-46b5-92b4-906544132732
Affected Issues
05401
mod - application/helpers/qanda_helper.php Diff File
mod - scripts/survey_runtime.js Diff File

Issue History

Date Modified Username Field Change
2011-08-17 14:18 user15287 New Issue
2011-08-17 19:18 mot Note Added: 16087
2011-08-17 19:21 mot File Added: 05401-00-maxlength-textarea-limit.diff
2011-08-18 16:10 Mazi Assigned To => tpartner
2011-08-18 16:10 Mazi Status new => assigned
2011-08-18 16:11 Mazi Note Added: 16098
2011-08-18 16:23 user15287 Note Added: 16099
2011-09-05 18:28 tpartner Note Added: 16230
2011-09-05 18:28 tpartner Status assigned => resolved
2011-09-05 18:28 tpartner Resolution open => fixed
2011-09-07 09:16 c_schmitz Note Added: 16237
2011-09-07 09:16 c_schmitz Status resolved => closed
2012-03-14 21:08 tpartner Changeset attached => Import 2012-03-09 13:30:34 Yii 55824b28