Welcome Guest, Not a member yet? Register   Sign In
Pasting from Word
#1

[eluser]Dan Bowling[/eluser]
I have two distinct problems when a user pastes from word into a simple text area that don't occur when they type in that same text area:

1) If there is special formatting, the SQL update statement fails because of special characters
Quote:Error Number: 1366
Incorrect string value: '\x95 Asds...' for column 'goals' at row 1

2) The update "appears" to succeed (doesn't generate an error) but the content pasted in does not appear, and it updates the field to blank. Even if the pasted text is just a word with no special formatting. Most of the time, this problem can be avoided by typing a space in the textarea before submitting.

Again, these two problems only happen when a user pastes from word.

Any ideas?
#2

[eluser]Colin Williams[/eluser]
You just need to clean the MS junk before insert (although any escaping method should take care of it). I know it's a mess, but it's necessary. I actually don't know of any really good tool/script to do this, but I haven't really looked all that far. We usually just tell clients to Paste at their own risk. When they go off and destroy their homepage a week later (which we honestly try to prevent) the blame is all on them, sadly. And I definitely wouldn't have WYSIWYG for user-generated content.
#3

[eluser]Dan Bowling[/eluser]
Yeah, that's my gut too. I think the expectation that Word should be compatible with textareas is crazy. I am worried about the inserts that don't fail, but update to nothing though.

As far as it all being escaped, I thought that was something CI did for me. Did I make a bad assumption? Or is it an issue with the Character Set compatibility?
#4

[eluser]Colin Williams[/eluser]
There's $this->db->escape(), $this->db->escape_string() for one-off escaping, but the insert() and update() methods, and mostly all AR methods as far as I know, escape the data.




Theme © iAndrew 2016 - Forum software by © MyBB