Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-06-24 22:49:02

daveh
Member
From: Bristol, UK
Registered: 2006-06-24
Posts: 33
Website

Garbage generated by doSlash() function

Is it possible for me to paste HTML markup into this topic WITHOUT it being translated (treated) as HTML? That is, I need to show you the problem with page content but can’t post it here!

The closest description I can give is that the doSlash() function is causing major problems with page content for me.

Thanks,
Dave

Last edited by daveh (2006-06-28 18:23:38)


—————
Dave-H

Offline

#2 2006-06-24 23:50:48

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Garbage generated by doSlash() function

FAQ

Offline

#3 2006-06-25 00:08:49

daveh
Member
From: Bristol, UK
Registered: 2006-06-24
Posts: 33
Website

Re: Garbage generated by doSlash() function

Oops, thanks Mary! Okay, here goes…

Having some very weird stuff happening here. I’m new to TP, almost new to PHP, and new to using a hosting service. Can it get any worse?? :-)

Anyway, to learn TP I installed it on my local PC and all worked fine, and continues to work. I have just created a new install (using ‘developer’ hosting plan by brinkster.com on Windows OS) but getting the following problem…

I log in to admin section. Browse to ‘presentation/pages’ and get content of ‘default’ page (similar problem with all other pages), which contains the default text as follows…

<code>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=“http://www.w3.org/1999/xhtml” xml:lang=“en” lang=“en”>
<head> <meta http-equiv=“content-type” content=“text/html; charset=utf-8” /> <link rel=“stylesheet” href=”<txp:css />” type=“text/css” media=“screen” /> <title><txp:page_title /></title>
</head>
etc.etc.
</code>
.
Then, I simply click ‘Save’ and the content gets re-written as…

<code>
<!DOCTYPE html PUBLIC \”-//W3C//DTD XHTML 1.0 Transitional//EN\”\r\n \“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\”>\r\n<html xmlns=\“http://www.w3.org/1999/xhtml\” xml:lang=\“en\” lang=\“en\”>\r\n<head>\r\n <meta http-equiv=\“content-type\” content=\“text/html; charset=utf-8\” />\r\n <link rel=\“stylesheet\” href=\”<txp:css />\” type=\“text/css\” media=\“screen\” />\r\n <title><txp:page_title /></title>\r\n</head>\r\n<body>\r\n<div id=\“accessibility\”>\r\n <a href=\”#content\” title=\“Go to content\”>Go to content</a> \r\n <a href=\”#sidebar-1\” title=\“Go to navigation\”>Go to navigation</a> \r\n
etc.etc.
</code>
.
So, I tracked this down to the doSlash() function being called from the page_save() function in txp_page.php and removed the call to doSlash() as follows…
<code> function page_save() { // extract(doSlash(gpsa(array(‘name’,‘html’,‘newname’,‘copy’)))); extract(gpsa(array(‘name’,‘html’,‘newname’,‘copy’))); if($newname && $copy) { safe_insert(“txp_page”, “name=’$newname’, user_html=’$html’”); page_edit(messenger(‘page’,$newname,‘created’)); } else { safe_update(“txp_page”,“user_html=’$html’”, “name=’$name’”); page_edit(messenger(‘page’,$name,‘updated’)); } }
</code>

So, that’s the problem. Any suggestions for a proper fix? (or even hints as to what may be wrong) as the doSlash() function is used too many times for me comment them all out in the TP sourcecode.

Ta,
Dave


—————
Dave-H

Offline

#4 2006-06-25 00:24:10

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Garbage generated by doSlash() function

Try adding to your .htaccess file:

php_flag magic_quotes_gpc 0

:)

Offline

#5 2006-06-25 02:05:59

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: Garbage generated by doSlash() function

The magic quotes setting shouldn’t make a difference. doSlash() is not the problem, disabling it will break things. Textpattern automatically detects whether or not magic quotes are on and adjusts itself accordingly.

What version of Textpattern are you using? Can you post your diagnostics please?

Last edited by zem (2006-06-25 02:09:04)


Alex

Offline

#6 2006-06-25 10:14:12

daveh
Member
From: Bristol, UK
Registered: 2006-06-24
Posts: 33
Website

Re: Garbage generated by doSlash() function

Zen, what diagnostics do you need from me?

TP version is 4.0.3


—————
Dave-H

Offline

#7 2006-06-25 11:06:47

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Garbage generated by doSlash() function

Admin > diagnostics :)
(How should I ask for help on the forum?)

Offline

#8 2006-06-25 11:10:58

daveh
Member
From: Bristol, UK
Registered: 2006-06-24
Posts: 33
Website

Re: Garbage generated by doSlash() function

Cheers Els, here you go…

Textpattern version: 4.0.3 (r1188)
Last Update: 2006-06-23 18:44:00/2006-06-23 18:16:07
Document root:
$path_to_site: c:\\sites\\single11\\ivikino\\webroot\\community
Textpattern path: c:\sites\single11\ivikino\webroot\community\textpattern
Permanent link mode: messy
upload_tmp_dir: C:\PHP\uploadtemp
Temp folder: C:\\WINDOWS\\TEMP
Site URL: www.tabularasaarts.com/community
PHP version: 5.1.1
Server Local Time: 2006-06-25 07:09:20
MySQL: 5.0.19-nt
Locale: English_United Kingdom.1252
Server: Microsoft-IIS/6.0
PHP Server API: cgi-fcgi
Server OS: Windows NT 5.2

Pre-flight check:
————————————
File Upload Path is not writable: c:\\sites\\single11\\ivikino\\webroot\\community\\files
————————————


—————
Dave-H

Offline

#9 2006-06-25 12:12:43

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: Garbage generated by doSlash() function

Does Mary’s .htaccess suggestion make a difference?


Alex

Offline

#10 2006-06-25 12:21:16

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: Garbage generated by doSlash() function

It’s possible this is a bug in PHP and/or IIS: bugs.php.net.


Alex

Offline

#11 2006-06-25 13:25:15

daveh
Member
From: Bristol, UK
Registered: 2006-06-24
Posts: 33
Website

Re: Garbage generated by doSlash() function

Unfortunately no, Mary’s .htaccess suggestion made no difference. I also tried removing the .htaccess file entirely but same result. There’s no report of a bug of this type on the php bug site.

I’ve checked my phpInfo against the hosting service one. They have the mbstring library enabled, which I don’t on my local PC. The host settings for it are…

<code>
mbstring
Multibyte Support…………………….enabled
Multibyte string engine……………….libmbfl
Multibyte (japanese) regex support……..enabled
Multibyte regex (oniguruma) version…….3.7.1

mbstring extension makes use of “streamable kanji code filter and converter”, which is distributed under the GNU Lesser General Public License version 2.1.

Directive……………………Local Value………..Master Value
mbstring.detect_order…………no value……………no value
mbstring.encoding_translation….Off………………..Off
mbstring.func_overload………..0………………….0
mbstring.http_input…………..pass……………….pass
mbstring.http_output………….pass……………….pass
mbstring.internal_encoding…….ISO-8859-1…………no value
mbstring.language…………….neutral…………….neutral
mbstring.strict_detection……..Off………………..Off
mbstring.substitute_character….no value……………no value
</code>

How does this compare to other peoples hosts?

(I am also comparing the mySQL info to see if any major differences.)


—————
Dave-H

Offline

#12 2006-06-26 01:33:58

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: Garbage generated by doSlash() function

There’s no report of a bug of this type on the php bug site.

The bug I linked to could cause this behaviour. Textpattern relies on get_magic_quotes_gpc() to handle slashes correctly; according to the bug report, that function doesn’t work correctly in some IIS environments.

What are the magic_quotes_* settings shown as in your phpinfo? (magic_quotes_gpc, magic_quotes_runtime, magic_quotes_sybase).


Alex

Offline

#13 2006-06-26 17:49:05

daveh
Member
From: Bristol, UK
Registered: 2006-06-24
Posts: 33
Website

Re: Garbage generated by doSlash() function

The bug I linked to could cause this behaviour.

Zem, I promise you that when I first clicked on that bug report link it took me to a different place than where you intended (hence my reply)!! I clicked it again just now and it seems to go to the right place. Ho hum. :-)

What are the magic_quotes_* settings shown as in your phpinfo? (magic_quotes_gpc, magic_quotes_runtime, magic_quotes_sybase).

Both my local PC and the hosted one report from phpInfo()…
<code>
……………………..Local Value….Master Value
magic_quotes_gpc……….On……………..On
magic_quotes_runtime……Off……………..Off
magic_quotes_sybase…….Off……………..Off
</code>

I ran the test.php page (from the bug report) and got the expected result of \“test\”.

[As an aside, a related issue is on the TP..Admin..Advanced Preferences page, everytime I click ‘Save’ the path values in ‘Temp folder’ and ‘File Upload Path’ gain an extra ‘\’ each time.]

Are we maybe looking in the wrong place – should we be looking at the unSlash function if there is such a thing ‘cos that’s what doesn’t seem to be working?

Cheers, Dave.
(And thanks for everyones input on this, I would really like to have TP running for my site.)


—————
Dave-H

Offline

#14 2006-06-26 17:54:42

daveh
Member
From: Bristol, UK
Registered: 2006-06-24
Posts: 33
Website

Re: Garbage generated by doSlash() function

In case it helps at all, I have created a user on the site should you wish to see the problem in action. You can put php code into the content if you want to test anything.

I’ll leave this user in place until either we manage to fix this, or I have to remove TP entirely.

(Edited to remove security compromising info. :) -Mary)

Last edited by Mary (2006-06-27 00:20:46)


—————
Dave-H

Offline

#15 2006-06-26 19:31:04

daveh
Member
From: Bristol, UK
Registered: 2006-06-24
Posts: 33
Website

Re: Garbage generated by doSlash() function

I hope this doesn’t distract the line of thought, but I replaced the entire doSlash() function with this one…

<code> function doSlash($in) { return $in; }
</code>

Which disables it entirely sitewide. This almost cures all the problems I’m having (except that I can’t put any apostrophes anywhere – but this might be a separate issue anyway).

(Is there a way to use the stripcslashes() function instead to escape the apostrophes?)

Also, what are the possible knock-on effects in doing this?

Dave


—————
Dave-H

Offline

Board footer

Powered by FluxBB