The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Word Processors & vBulletin UTF-8 Stripped Posts (Possible Fix?)
Hi all, I'm fairly new to the inner workings of vBulletin and I found myself tackling a bug when users would post directly from MS Word or Appleworks. Now these programs have the SmartQuotes and AutoCorrect options and those seemed to be Windows 1252 encodings so when the user would enter their text with copy and paste, what was happening was the moment the post hit a non UTF-8 character, the rest of the post would get cut off. I didn't have much luck finding any help with some vBulletin googling. After a lot of searching around though I found a helpful post on the php forums. All it required I do was add the following bolded code in includes/class_core.php:
Code:
function htmlspecialchars_uni($text, $entities = true) { $text = mb_convert_encoding($text,"HTML-ENTITIES","auto"); return str_replace( // replace special html characters array('<', '>', '"'), array('<', '>', '"'), preg_replace( // translates all non-unicode entities '/&(?!' . ($entities ? '#[0-9]+' : '(#[0-9]+|[a-z]+)') . ';)/si', '&', $text ) ); } Thanks for any insight, orth |
#2
|
|||
|
|||
I have this problem as well. It seems to work fine for previews, but once you actually make the post it screws everything up.
Is that how you experienced it as well? I havn't seen any other recommendations on this, so unless someone (From the vB Team maybe?) advises otherwise, I think I'll use this fix. Anyone know if this will be an included fix in future versions? Thanks |
#3
|
||||
|
||||
You should report bugs to the vBulletin Bug Tracker (http://www.vbulletin.com/forum/project.php?projectid=6).
|
#4
|
|||
|
|||
I tried this fix and unfortunately it didn't work for me.
I'm not sure that it is really a bug so much as a poor choice of character encoding on my part. Choosing UTF-8 may have let me avoid this. I tried fixing it myself, with varying amounts of success. I tried placing an str_replace() that replaces smartquotes and other special characters with their $blah; counter parts. This gave me some improvement, however, I couldn't find the most optimal place to put this. I tried having it change the $dataman->['pagetext'] after the various _presave hooks but that didn't fix all cases. It would only work with edits || new posts, not both, for example. Could anyone point me to which hook would be caught by all posts/post edits and which variable would be best to change at that hook? I think it would be fairly trivial to do this if I didnt use a hook, but that of course makes maintaing updates much harder. Here is the str_replace I'm using... PHP Code:
Thanks in advance. |
#5
|
|||
|
|||
Just stumbled upon this post. Thanks for the insightful information people. Have you since, found a better solution? I see people inserting text which is cut & pasted from Word docs. What a mess.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|