jetpack icon indicating copy to clipboard operation
jetpack copied to clipboard

Contact Form: wrong subject line when site title includes an apostrophe

Open jeherve opened this issue 12 years ago • 3 comments

Steps to reproduce:

  1. Create a default form (no custom options, just add the form without editing the form content) using the form builder: the shortcode will be as follows:
[contact-form][contact-field label='Name' type='name' required='1'/][contact-field label='Email' type='email' required='1'/][contact-field label='Website' type='url'/][contact-field label='Comment' type='textarea' required='1'/][/contact-form] 
  1. Go to Settings > General in your dashboard, and change your site title to include an apostrophe, e.g. "the cat's pajamas"
  2. Insert a default form again: the shortcode now includes a subject line, including a square bracket:
 [contact-form subject='[the cat%26#039;s pajamas'][contact-field label='Name' type='name' required='1'/][contact-field label='Email' type='email' required='1'/][contact-field label='Website' type='url'/][contact-field label='Comment' type='textarea' required='1'/][/contact-form] 

Reported in #2065950-org

jeherve avatar Sep 16 '14 21:09 jeherve

I think this is what's happening:

  1. A default subject is generated
  2. The attributes (including the subject) are passed through unesc_attr(). Certain characters in particular (" ' & ,) are unencoded.
  3. After passing through some other steps this value is compared to the saved default. When they are found to be different (due to step 2) the code falsely concludes that the user has set the subject to this value and includes it in the shortcode (escaped again later in the function).

Looking back at this code, adding an esc_attr (as shown below) seems to solve the problem. I would appreciate a 2nd opinion as I don't feel I've entirely got to grips with this code just yet, but I can make a pull request if desired.

if ( isset( $this->defaults[$key] ) && $this->defaults[$key] == esc_attr( $value ) ) {
    continue;
}

chrisdc avatar Sep 17 '14 18:09 chrisdc

This issue has been marked as stale. This happened because:

  • It has been inactive in the past 6 months.
  • It hasn’t been labeled `[Pri] Blocker`, `[Pri] High`.

No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation.

stale[bot] avatar Jul 07 '18 00:07 stale[bot]

This issue has been marked as stale. This happened because:

  • It has been inactive in the past 6 months.
  • It hasn’t been labeled `[Pri] Blocker`, `[Pri] High`, etc.

No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation.

github-actions[bot] avatar Jul 26 '21 00:07 github-actions[bot]