Error in the way Admin-->Plugins page displays

hyperbole

Joined: 2007-07-11
Posts: 6
Posted: Thu, 2007-10-18 22:31

A client is using Gallery2 embedded in Drupal. He is using Gallery 2.2 and has it installed on two different systems. On the first system, the PHP version is 5.1.6, on the other it is 5.2.1. Other than that everything between the two systems is the same.

On the second system, the Admin-->Plugins page doesn't display properly. The font used to display the list of plugins is very small. On the first system this doesn't seem to be a problem and the plugins list seems to display normally.

On the second system, when we go to Admin-->Plugins, the page has two instances of '<html> <head>' in the page source. The first is the normal <head> section for the page. The second <html> <head> appear in the <body> of the page and contains the the head information generated by Gallery for displaying the Plugins page. This is probably (as I explain below) because, splitHtml is failing to recognize the head and body secitons of the page.

I think I have traced this to a problem with the way a regular expression is being executed in the file gallery2/modules/core/classes/GalleryTheme.class at about line 1920 in the function splitHtml.

This function contains the line:
if (preg_match('|<head>(.*)</head>.*?<body.*?>(.*)</body>|s', $mainHtml, $match) == 1) {
which doesn't seem to divide the $mainHtlm string into the parts head and body for the generated page for plugins. This causes the returned results to only contain a bodyHtml section.

Changing the above line to:
if (preg_match('|<head>(.*?)</head>.*?<body[^>]*?>(.*)</body>|is', $mainHtml, $match) == 1) {
splitHtml splits $mainHtml into a headHtml and bodyHtml section in the returned results. This allows the page to be displayed properly inside Drupal.

I assume this is a change caused by the differences in the way the two versions of PHP execute the regular expression.

I looked in the SourceForge Bug Tracker to see if this problem was mentioned there, but saw no mention of it.

It may be that this problem is being caused by the way AdminPlugins.class is generating the html for the Plugins list, but I couldn't find any problems with that.

It also may be that this problem is high-lighting a problem with the way GalleryEmbeded.class is transforming the page when splitHtml hands it an unexpected result. I didn't really look into that.

I would appreciate if anyone with knowledge of this could comment on what I've found. Should I enter this in the Bug Tracker?

Carl.

Login or register to post comments
valiant

Joined: 2003-01-04
Posts: 32322
Posted: Thu, 2007-10-18 23:09

> On the second system, when we go to Admin-->Plugins, the page has two instances of '<html> <head>' in the page source.

this was a bug that has been fixed a few days ago.
see:
http://fisheye3.cenqua.com/changelog/gallery/trunk/gallery2/modules/core/classes?cs=17093

> I assume this is a change caused by the differences in the way the two versions of PHP execute the regular expression.

php 5.2.0 introduced limits on the regular expression engine and the defaults for those limits silently break a lot of code.
we've fixed this code to work around the limit.

the bug id, diffs etc are all referenced in the above URL.

--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage

Login or register to post comments
hyperbole

Joined: 2007-07-11
Posts: 6
Posted: Fri, 2007-10-19 00:53

Thanks.

Carl.

Login or register to post comments
jettyrat
jettyrat's picture

Joined: 2005-12-30
Posts: 32
Posted: Thu, 2008-05-29 19:39

I'm able to reproduce this bug still in embedded mode. The plugins page works fine until some size is exceeded and then the page is output exactly as described above with Gallery sending out it's own head and body tags even when embedded.

Gallery version = 2.2.4 core 1.2.0.6
PHP version = 5.2.4 apache2handler
Webserver = Apache/2.2.6 (Win32) PHP/5.2.4
Database = mysqli 5.1.22-rc-community, lock.system=database

Login or register to post comments