The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Escape Characters and Quotation Marks

I am sure this is a problem common to many PHP installations but I was wondering how to fix it specifically in a form-tools installation?

I have a text area on a form. If I add
Quote:this is a quote by me; "why do I keep getting escape characters repeated?"

each time the submission is updated I get extra escape characters
Quote:this is a quote by me; \\\"why do I keep getting escape characters repeated?\\\"
then, after 3 or 4 updates
Quote:this is a quote by me; \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"why do I keep getting escape characters repeated?\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"

To get around storage of this I use stripslashes and str_replace functions in a hook in ft_update_submission, start. But although it is getting stored correctly in MYSQL it still insists on displaying them as above?

Is there is a global variable or whatever that I can set to prevent this behaviour rather than use code hooks?

I have solved this problem but it took some finding.

I have a code hook in ft_update_submission,start. Although it appeared to be working there must have been a problem with it. However this problem was not flagged in edit_submission.php i.e.
list($g_success, $g_message) = ft_update_submission($form_id, $submission_id, $request);

  // if there was any problem udpating this submission, make a special note of it: we'll use that info to merge the current POST request
  // info with the original field values to ensure the page contains the latest data (i.e. for cases where they fail server-side validation)
  if (!$g_success)
      $failed_validation = true;

Both $g_success and $g_message were being returned as NULL. Later in edit_submission.php there is a call thus:-
$grouped_fields = ft_get_grouped_view_fields($view_id, $tab_number, $form_id, $submission_id);
if ($failed_validation)
    $grouped_fields = ft_merge_form_submission($grouped_fields, $_POST);

Because $failed_validation was true, the merge code here (I think) just kept adding the POST'd values to themselves and (I think) was causing the multiple slashes to appear.

I corrected my hook and everything behaved itself again

I wonder if this should be flagged up to Ben/Joe??

Hey Grahame,

Thanks for posting your solution. We'll take a closer look at this. Could you post into our bug tracker please? Thanks so much.



Would be happy to but, actually, I have done a little more digging around on this.

I had code in the hooks manager for 'ft_update_submission, start' and 'end'. When ft_update_submission was called by edit_submission.php thus
list($g_success, $g_message) = ft_update_submission($form_id, $submission_id, $request);
the variables $g_success and $g_message were being returned as NULLs. This then resulted in the $failed_validation being true. This was irrespective of the failure or success of my code.

Now although my code was actually working, there are two override variables in the hook manager... $success and $message which I was not manipulating. They were defaulting to NULL.

So I don't think this is a bug per se but rather my misunderstanding that there was a requirement for $success and $message to be set to true by the code in the hook??

Forum Jump:

Users browsing this thread: 1 Guest(s)