• Hi,

    Backslashes are added to the text area field in notification emails when using apostrophe (‘).

    I tried switching off magic_quotes_gpc in php.ini.
    I tried updating the text area field prior to db saving using the acf/update_value filter.

    Your help would be appreciated.

    Regards.

    Patrick

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter psergerie

    (@psergerie)

    Hi again !

    Issue precision : Backslashes are added to notification emails only when using field shortcodes using insert field button in WYSIWYG AF editor (example : {field: field_name}).

    Regards,

    Patrick

    Thread Starter psergerie

    (@psergerie)

    Hi again !

    I was able to remove backslashes from the AF WYSIWYG editor by hacking $html on core-email.php (line 152) as follow :

    // Construct email HTML
    		$html = sprintf(
    			'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
    			<html xmlns="https://www.w3.org/1999/xhtml">
    				<head>
    					<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    					<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    					<title>%s</title>
    					<style>%s</style>
    				</head>
    				<body>
    					%s
    				</body>
    			</html>',
    			$subject,
    			$this->get_email_style( $email, $form ),
    			<strong>stripslashes( $content )</strong>
    		);

    For some reason, I am unable to alter $content using the af/form/email/content filter.

    Is there a way to stripslashes( $content ) without hacking core files ?

    Regards,

    Patrick

    Thread Starter psergerie

    (@psergerie)

    Please forget the tag in my previous reply (code section), I just wanted to highlight changes to $html variable.

    Plugin Author fabianlindfors

    (@fabianlindfors)

    This seems odd!

    Are the backslashes added to the form post meta when saving the form or are they added when the email is constructed?

    Thread Starter psergerie

    (@psergerie)

    Only when email are constructed. Please refer to my previous reply where I have added the stripslashes() function to solve the problem (line 152 of core-email.php).

    Thread Starter psergerie

    (@psergerie)

    Hi Fabien,

    Any thoughts or ideas since our last chat ?

    Please let me know if I can expect a fix soon so I can move forward with my design decisions.

    Best regards,

    Patrick Sergerie

    Plugin Author fabianlindfors

    (@fabianlindfors)

    Hi! This must have slipped my mind, thank you for reminding me!

    Wordpress will automatically add slashes regardless of the magic_quotes setting. I have pushed a new commit to the Github repo which contains a fix for your problem. This will of course be included in the next release.

    Hope it works! https://github.com/advancedforms/advanced-forms

    Thread Starter psergerie

    (@psergerie)

    Great ! Thanks Fabian !

    Thread Starter psergerie

    (@psergerie)

    Hi Fabien,

    Another (friendly !) reminder that this issue is not yet solved ! I had to modify core again after updating to your last release…

    Best regards,

    Patrick

    Plugin Author fabianlindfors

    (@fabianlindfors)

    Hi!

    So sorry to hear that you are experiencing this issue again. I’m not quite sure why the issue has reappeared now as my previous solution hasn’t been removed. My original solution was a bit different from yours in that I added the stripslashes call to the field include for every WYSIWYG field instead of the full email.

    What type is the field into which you are typing the apostrophe which is causing the issue?

    Thank you for patience!

    Thread Starter psergerie

    (@psergerie)

    Hi Fabian,

    Sorry for replying late, lot’s of work these days, preparing for Gutenberg and other hot topics !

    To answer your question, both text fields and textarea fields behave the same.

    Hope that’ll help.

    Regards,

    Patrick

    Plugin Author fabianlindfors

    (@fabianlindfors)

    I’m having a hard time replicating this and apostrophes work as expected with both the text, text area, and WYSIWYG fields. Could you try disabling all other plugins and switching to a twenty-something theme?

    If that doesn’t work, may I ask what PHP version you are running?

    Thank you!

    Thread Starter psergerie

    (@psergerie)

    Hi Fabian,

    Sorry again for the delay between my replies…

    No luck…still the exact same behavior.

    I tried disabling all other plugins and switched to a “standard” wordpress theme (currently working with a Genesis theme) without success. I also have upgraded to PHP to version 7.2.

    Also, I have just updated your plugin to version 1.5.3 and retest and found backslashes again in all fields previously mentionned. Again, adding stripslashes() function to $content variable in core-emails.php (now at line 148) solve the problem.

    Hope we’ll figure out a permanent solution soon…

    Best regards.

    Patrick Sergerie

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Backslashes added to notification emails’ is closed to new replies.