I used the plugin where it\’s installed at
http://www.mysociety.org/call-for-proposals-2009/
A character limit is set, but \’preview\’ and \’submit\’ behave in different ways in that they count \’ (ascii single quote) differently – I think \’submit\’ is counting it as two characters, preview as one. I discovered this by previewing something that worked fine, and then finding I couldn\’t submit it.
Edited to add: previewing this bug report sheds a little light in that all instances of \’ show up as true apostrophes preceded by a backslash. Which in any event is rather ugly. It didn\’t do that in the instance that led to the bug report, but (perhaps related) I\’ve updated Firefox since then. Now using 3.5.2. I think it was previously 3.0.2. I\’m on a Powerbook G4, under MacOS X.4.11.
Ah the dreaded backslashes! I can never truly conquer them. I thought I had gotten close but it seems that the latest update to Wordpress has reversed some of that work on me.
PHP has a option called “magic quotes”, that when you submit something online such as a form, it adds a blackslash to all apostrophes. I can’t remember the reason. So then, in the backend, you may need to strip them before you process. You may need them before you add the data to a database, otherwise they break you’re SQL query. Wordpress also does some “prevention” on this and I’m never sure where and when it does it between versions. It always works within Wordpress, but I’m always playing catchup.
And then there is AJAX.
I’ll have a look into it and fix it for the next release, hopefully.
So I did some tests, the situation doesn’t look great. I basically tested with the Content widget and title option enabled. Oddly title and content would sometimes act differently.
Worst combination of options: magic quotes enabled and using AJAX. Preview on Content seems to be failing all the time now, that certainly wasn’t the case with older versions of Wordpress.
Wordpress 2.8.2
+++++++++++++++
Magic Quotes: ON
================
Title | Content
AJAX: On
--------
New-Post-Preview: FAIL | FAIL
New-Post-Submit : FAIL | FAIL
AJAX: Off
---------
New-Post-Preview: OK | FAIL
New-Post-Submit : OK | OK
Magic Quotes: OFF
=================
AJAX: On
--------
New-Post-Preview: OK | FAIL
New-Post-Submit : OK | OK
AJAX: Off
---------
New-Post-Preview: OK | FAIL
New-Post-Submit : OK | OK
I’m doing my nut trying to fix this.
I have it mostly working for AJAX and Magic Quotes enabled… but Wordpress *still* insists on unnecessarily adding slashes. Whats worse, it doesn’t do it in a consistent manner. Passing the content through the “the_content” filter means it passes through wptexturize function. This does silly stuff like turn apostrophes into fancy apostrophes around words. It also adds back in extra slashes… but only around specific characters, not all characters that would have slashes given the magic quote setting. I can’t just pass the content through stripslashes() because that will remove genuine backslashes in the content!
This problem can be found, not just in the Content widget, but in the Excerpt and Custom Field widget (because they all use “the_content” filter in Wordpress). I will do my best to make an approximate fix for it, but it’ll never be perfect.
And I haven’t even tackled the other six other cases yet!
Mark said:
Sorry for opening this can of worms!
Don’t worry about it. It needs to be fixed. It’s forced me to do some work that I’ve been leaving aside so I’m doing a bit of refactoring of the widget code. This will be better in the long run for new features too as well.
My progress is slow so far because as I work on it I keep realising new cases to test to truly solve it. So far I’ve made sure that for the normal form the basic textfields and textareas work correctly when Magic Quotes are ON.
Magic Quotes: ON ================ Widget Screen : Form Hacker : [AJAX: On] Title | Content | Excerpt | CF: TextArea | CF: TextField -------------------------------------------------------------------------- New-Post-Preview : OK | OK | OK | OK | OK New-Post-Submit : OK | OK | OK | OK | OK Edit-Post-Preview: Edit-Post-Submit : [AJAX: Off] Title | Content | Excerpt | CF: TextArea | CF: TextField -------------------------------------------------------------------------- New-Post-Preview : OK | OK | OK | OK | OK New-Post-Submit : OK | OK | OK | OK | OK Edit-Post-Preview: Edit-Post-Submit : Magic Quotes: OFF ================= Widget Screen : Form Hacker : [AJAX: On] Title | Content | Excerpt | CF: TextArea | CF: TextField -------------------------------------------------------------------------- New-Post-Preview : New-Post-Submit : Edit-Post-Preview: Edit-Post-Submit :
Hopefully the work will progress a little faster now with the majority of the refactoring complete.
I’ve sorted out “Magic Quotes On” now. Everything seems to work, the character and word counts seem correct too. You can grab it right now from the dev version on wordpress.org.
If you’ve got Magic Quotes off, you’re going to have to wait a bit longer, though this version should be pretty strong.
Wordpress 2.8.2 +++++++++++++++ Magic Quotes: ON ================ Widget Screen : OK Form Hacker : OK [AJAX: On] Title | Content | Excerpt | CF: TextArea | CF: TextField -------------------------------------------------------------------------- New-Post-Preview : OK | OK | OK | OK | OK New-Post-Submit : OK | OK | OK | OK | OK Edit-Post-Preview: OK | OK | N/A | N/A | N/A Edit-Post-Submit : OK | OK | N/A | N/A | N/A [AJAX: Off] Title | Content | Excerpt | CF: TextArea | CF: TextField -------------------------------------------------------------------------- New-Post-Preview : OK | OK | OK | OK | OK New-Post-Submit : OK | OK | OK | OK | OK Edit-Post-Preview: OK | OK | N/A | N/A | N/A Edit-Post-Submit : OK | OK | N/A | N/A | N/A Magic Quotes: OFF ================= Widget Screen : Form Hacker : [AJAX: On] Title | Content | Excerpt | CF: TextArea | CF: TextField -------------------------------------------------------------------------- New-Post-Preview : New-Post-Submit : Edit-Post-Preview: Edit-Post-Submit : [AJAX: Off] Title | Content | Excerpt | CF: TextArea | CF: TextField -------------------------------------------------------------------------- New-Post-Preview : New-Post-Submit : Edit-Post-Preview: Edit-Post-Submit :
Good news. Only some minor mods were required for Magic Quotes off. I’m going to be releasing a new version fairly soon with these changes.
Magic Quotes: ON ================ Widget Screen : OK Form Hacker : OK [AJAX: On] Title | Content | Excerpt | CF: TextArea | CF: TextField -------------------------------------------------------------------------- New-Post-Preview : OK | OK | OK | OK | OK New-Post-Submit : OK | OK | OK | OK | OK Edit-Post-Preview: OK | OK | N/A | N/A | N/A Edit-Post-Submit : OK | OK | N/A | N/A | N/A [AJAX: Off] Title | Content | Excerpt | CF: TextArea | CF: TextField -------------------------------------------------------------------------- New-Post-Preview : OK | OK | OK | OK | OK New-Post-Submit : OK | OK | OK | OK | OK Edit-Post-Preview: OK | OK | N/A | N/A | N/A Edit-Post-Submit : OK | OK | N/A | N/A | N/A Magic Quotes: OFF ================= Widget Screen : OK Form Hacker : OK [AJAX: On] Title | Content | Excerpt | CF: TextArea | CF: TextField -------------------------------------------------------------------------- New-Post-Preview : OK | OK | OK | OK | OK New-Post-Submit : OK | OK | OK | OK | OK Edit-Post-Preview: OK | OK | N/A | N/A | N/A Edit-Post-Submit : OK | OK | N/A | N/A | N/A [AJAX: Off] Title | Content | Excerpt | CF: TextArea | CF: TextField -------------------------------------------------------------------------- New-Post-Preview : OK | OK | OK | OK | OK New-Post-Submit : OK | OK | OK | OK | OK Edit-Post-Preview: OK | OK | N/A | N/A | N/A Edit-Post-Submit : OK | OK | N/A | N/A | N/A
Mark
Guest
August 28th, 2009 at 10:54 am
Oh dear, the backslashes appear in the finished article too.
Another bug in this forum: in the post above my name is a link, but clicking on it yields:
Alert
The URL is not valid and cannot be loaded.
Permalink | Quote