#31632 closed defect (bug) (fixed)
Don't strip newline in esc_url() when protocol is mailto:
| Reported by: | danielbachhuber | Owned by: | danielbachhuber |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.3 |
| Component: | Formatting | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
Description
esc_url() strips encoded newlines when it shouldn't.
The genesis of newline stripping is r4148. mailto was added as a mentioned protocol in r8743, but it doesn't appear there was any technical change, only the PHPdoc mention.
Here's the failing testcase:
$body = <<<EOT Hi there, I thought you might want to sign up for this newsletter EOT; $email_link = 'mailto:?body=' . rawurlencode( $body ); // Expected: mailto:?body=Hi%20there%2C%0A%0AI%20thought%20you%20might%20want%20to%20sign%20up%20for%20this%20newsletter var_export( $email_link ); // Actual: mailto:?body=Hi%20there%2CI%20thought%20you%20might%20want%20to%20sign%20up%20for%20this%20newsletter $email_link = esc_url( $email_link ); var_export( $email_link );
Attachments (1)
Change History (12)
This ticket was mentioned in Slack in #core by danielbachhuber. View the logs.
12 years ago
This ticket was mentioned in Slack in #core by jorbin. View the logs.
11 years ago
#8
@
11 years ago
I think that this is an edgecase, but one worth supporting. mailto is an acceptable protocal to be run through esc_url and it allows new lines. The fact that this contains unit tests means that the cost of the supporting the edge case is low.
#9
@
11 years ago
I'm fine with letting it in if others feel strongly, but I still think it's an significant edge-case that doesn't realistically need to be supported.
The unit tests should be expanded to cover other use-cases as well. It should show it in action, and that it still works as intended for other url forms (assuming that there isn't another test that handles that already)
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Don't strip newline in esc_url when protocol is mailto: