phpBB 3.1.10 > 3.2.0 "Unterminated XPath Expression"

Get help with installation and running phpBB 3.2.x here. Please do not post bug reports, feature requests, or extension related questions here.
Post Reply
Ryan JB
Registered User
Posts: 7
Joined: Sun Apr 02, 2017 4:08 pm

phpBB 3.1.10 > 3.2.0 "Unterminated XPath Expression"

Post by Ryan JB » Sun Apr 02, 2017 4:45 pm

Hello all,

I admin two phpBB boards running vanilla 3.1.10, and just got around to updating both to the new 3.2.0 version this morning.

Both boards were previously running on php 5.3 (which phpBB 3.2.0 can't run on), so I switched up to php 5.4 for both servers, wiped all files other than images, files, store and the config.php file, uploaded the whole 3.2.0 fresh install package (minus those files), and proceeded to run the db update script from the install directory.

The first board updated correctly with no problems, and now seems to be running just fine.

The second board, however, doesn't make it through the database update procedure, terminating with a red "Unterminated XPath Expression" error at 33% complete, and leaving the database version as "3.2.0-dev" (rather than 3.1.10, as might be expected?)

I've searched for this error, but can't seem to find any info on what might be causing it, or why it would happen on one of the two boards but not the other, given the same vanilla update process.

I've reverted back to 3.1.10 for that board now, but would like to get the 3.2.0 update done.

I don't suppose anyone has any ideas? :)

Ryan
Attachments
phpBBError.png

User avatar
JoshyPHP
Code Contributor
Posts: 1058
Joined: Mon Jul 11, 2011 12:28 am

Re: phpBB 3.1.10 > 3.2.0 "Unterminated XPath Expression"

Post by JoshyPHP » Mon Apr 03, 2017 6:11 am

If you send me a dump of your phpbb_bbcodes table I'll take a look at it and tell you whether it's related.
I wrote the thing that does BBCodes in 3.2.

Ryan JB
Registered User
Posts: 7
Joined: Sun Apr 02, 2017 4:08 pm

Re: phpBB 3.1.10 > 3.2.0 "Unterminated XPath Expression"

Post by Ryan JB » Mon Apr 03, 2017 4:06 pm

Hey there,

Thanks for the reply. Both forums (the one that updated correctly and the one which has the error) only have the same three custom BBCodes (two of them simple formatting codes for center and strikethrough, and one to insert an image sourced from a web script), but as an experiment, I did just try deleting all three custom codes from the problem forum and re-running the installer... And, sadly, again, it produces the same error. :P

But just in case, here's a dump of the phpbb_bbcodes table from before the update script was run:

Code: Select all

-- phpMyAdmin SQL Dump
-- version 4.0.10.18
--
-- Server version: 10.0.29-MariaDB-cll-lve
-- PHP Version: 5.6.30

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

CREATE TABLE IF NOT EXISTS `phpbb_bbcodes` (
  `bbcode_id` smallint(4) unsigned NOT NULL DEFAULT '0',
  `bbcode_tag` varchar(16) COLLATE utf8_bin NOT NULL DEFAULT '',
  `bbcode_helpline` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
  `display_on_posting` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `bbcode_match` text COLLATE utf8_bin NOT NULL,
  `bbcode_tpl` mediumtext COLLATE utf8_bin NOT NULL,
  `first_pass_match` mediumtext COLLATE utf8_bin NOT NULL,
  `first_pass_replace` mediumtext COLLATE utf8_bin NOT NULL,
  `second_pass_match` mediumtext COLLATE utf8_bin NOT NULL,
  `second_pass_replace` mediumtext COLLATE utf8_bin NOT NULL,
  PRIMARY KEY (`bbcode_id`),
  KEY `display_on_post` (`display_on_posting`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

And just for completeness, I checked the dump of the same table from after the failed update, and it's exactly the same, as far as I can see.

Not sure that helps at all?

Ryan

User avatar
JoshyPHP
Code Contributor
Posts: 1058
Joined: Mon Jul 11, 2011 12:28 am

Re: phpBB 3.1.10 > 3.2.0 "Unterminated XPath Expression"

Post by JoshyPHP » Mon Apr 03, 2017 7:19 pm

I was thinking about the table's content, to see what's in those BBCodes. The error message almost certainly comes from the BBCode handling.
Ryan JB wrote:
Mon Apr 03, 2017 4:06 pm
one to insert an image sourced from a web script
That's probably the one that triggers that error. Either that or possibly a weird interaction with a custom style. Something related to JavaScript and an unbalanced number of { and }.

Send me a dump of the content of your phpbb_bbcodes table and we'll know for sure. I don't recommend deleting your BBCodes, at worst you can simply probably edit template/HTML to remove their JavaScript. If the issue is with custom styles, try uninstalling them.
I wrote the thing that does BBCodes in 3.2.

Ryan JB
Registered User
Posts: 7
Joined: Sun Apr 02, 2017 4:08 pm

Re: phpBB 3.1.10 > 3.2.0 "Unterminated XPath Expression"

Post by Ryan JB » Mon Apr 03, 2017 7:44 pm

But as per my previous post, the error still occurs without the BB Codes, as above - that's the dump of the empty table just before I tried to update after deleting the codes, during which the same error occurred at the same point in the update process.

Whether or not that table is empty, the same error occurs.

EDIT: also, the forum is vanilla and doesn't have any styles other than the default Prosilver style that ships with phpBB - in fact, as I mentioned, I've actually deleted the entire forum save for the files/images/store and config.php and used an entirely fresh complete install of phpBB 3.2. The error is occurring during the "update database only" option in the installer.

Ryan

User avatar
JoshyPHP
Code Contributor
Posts: 1058
Joined: Mon Jul 11, 2011 12:28 am

Re: phpBB 3.1.10 > 3.2.0 "Unterminated XPath Expression"

Post by JoshyPHP » Mon Apr 03, 2017 8:09 pm

If the table is empty then there's no explanation for this error, that's why I'd rather work on the assumption that it's not. Do you still have a copy of those custom BBCodes somewhere? I also work on the assumption that this is a staging server, not a live installation.
I wrote the thing that does BBCodes in 3.2.

Ryan JB
Registered User
Posts: 7
Joined: Sun Apr 02, 2017 4:08 pm

Re: phpBB 3.1.10 > 3.2.0 "Unterminated XPath Expression"

Post by Ryan JB » Mon Apr 03, 2017 9:50 pm

Um... But it would appear to be a wrong assumption, as the dump above is exactly as output from phpMyAdmin before running the update script, which failed with the error as in my first post. The table is empty. There are no custom BBCodes on the forum at the point of updating.

Or are you suggesting that there might be some other way that a previously existant BBCode could cause a problem here even though it no longer exists in that table?

This is a live forum, but a quiet enough one that I can switch it off temporarily to perform updates without problems. I have a full db and filesystem backup which I've reinstated after each attempt at performing the update, so deleting BBCodes and tinkering with data to experiment with the updater is no big issue.

Are there any other tables in the database that might cause a failure of this kind at this point during the "update database only" process?

Ryan

User avatar
JoshyPHP
Code Contributor
Posts: 1058
Joined: Mon Jul 11, 2011 12:28 am

Re: phpBB 3.1.10 > 3.2.0 "Unterminated XPath Expression"

Post by JoshyPHP » Mon Apr 03, 2017 10:33 pm

Post the custom BBCodes.
I wrote the thing that does BBCodes in 3.2.

Ryan JB
Registered User
Posts: 7
Joined: Sun Apr 02, 2017 4:08 pm

Re: phpBB 3.1.10 > 3.2.0 "Unterminated XPath Expression"

Post by Ryan JB » Mon Apr 03, 2017 11:03 pm

The SQL dump of the table from the 3.1.10 db, with BBCodes still active, is as below:

Code: Select all

-- phpMyAdmin SQL Dump
-- version 4.0.10.18
--
-- Host: localhost:3306
-- Server version: 10.0.29-MariaDB-cll-lve
-- PHP Version: 5.6.30

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Table structure for table `phpbb_bbcodes`
--

CREATE TABLE IF NOT EXISTS `phpbb_bbcodes` (
  `bbcode_id` smallint(4) unsigned NOT NULL DEFAULT '0',
  `bbcode_tag` varchar(16) COLLATE utf8_bin NOT NULL DEFAULT '',
  `bbcode_helpline` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
  `display_on_posting` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `bbcode_match` text COLLATE utf8_bin NOT NULL,
  `bbcode_tpl` mediumtext COLLATE utf8_bin NOT NULL,
  `first_pass_match` mediumtext COLLATE utf8_bin NOT NULL,
  `first_pass_replace` mediumtext COLLATE utf8_bin NOT NULL,
  `second_pass_match` mediumtext COLLATE utf8_bin NOT NULL,
  `second_pass_replace` mediumtext COLLATE utf8_bin NOT NULL,
  PRIMARY KEY (`bbcode_id`),
  KEY `display_on_post` (`display_on_posting`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

--
-- Dumping data for table `phpbb_bbcodes`
--

INSERT INTO `phpbb_bbcodes` (`bbcode_id`, `bbcode_tag`, `bbcode_helpline`, `display_on_posting`, `bbcode_match`, `bbcode_tpl`, `first_pass_match`, `first_pass_replace`, `second_pass_match`, `second_pass_replace`) VALUES
(13, 'center', 'Centred text: [center]text[/center]', 1, '[center]{TEXT}[/center]', '<div style="text-align: center; width: 100%;">{TEXT}</div>', '!\\[center\\](.*?)\\[/center\\]!ies', '''[center:$uid]''.str_replace(array("\\r\\n", ''\\"'', ''\\'''', ''('', '')''), array("\\n", ''"'', ''&#39;'', ''&#40;'', ''&#41;''), trim(''${1}'')).''[/center:$uid]''', '!\\[center:$uid\\](.*?)\\[/center:$uid\\]!s', '<div style="text-align: center; width: 100%;">${1}</div>'),
(14, 's', 'Strike-through: &quot;[s]text[/s]&quot;', 1, '[s]{TEXT}[/s]', '<span style="text-decoration: line-through">{TEXT}</span>', '!\\[s\\](.*?)\\[/s\\]!ies', '''[s:$uid]''.str_replace(array("\\r\\n", ''\\"'', ''\\'''', ''('', '')''), array("\\n", ''"'', ''&#39;'', ''&#40;'', ''&#41;''), trim(''${1}'')).''[/s:$uid]''', '!\\[s:$uid\\](.*?)\\[/s:$uid\\]!s', '<span style="text-decoration: line-through">${1}</span>'),
(15, 'regnus=', 'Regnus text: [regnus=script]label[/regnus]', 1, '[regnus={TEXT1}]{TEXT2}[/regnus]', '<img src="http://www.regnus-scripting.info/parsers/web/Regnus.php?output=image&amp;imagewidth=450&amp;script={TEXT1}&amp;protocol=http&amp;label={TEXT2}" alt="Generated with Regnus: www.regnus-scripting.info" />', '!\\[regnus\\=(.*?)\\](.*?)\\[/regnus\\]!ies', '''[regnus=''.str_replace(array("\\r\\n", ''\\"'', ''\\'''', ''('', '')''), array("\\n", ''"'', ''&#39;'', ''&#40;'', ''&#41;''), trim(''${1}'')).'':$uid]''.str_replace(array("\\r\\n", ''\\"'', ''\\'''', ''('', '')''), array("\\n", ''"'', ''&#39;'', ''&#40;'', ''&#41;''), trim(''${2}'')).''[/regnus:$uid]''', '!\\[regnus\\=(.*?):$uid\\](.*?)\\[/regnus:$uid\\]!s', '<img src="http://www.regnus-scripting.info/parsers/web/Regnus.php?output=image&amp;imagewidth=450&amp;script=${1}&amp;protocol=http&amp;label=${2}" alt="Generated with Regnus: www.regnus-scripting.info" />');

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
But I should mention again, the same error occurs whether or not this table is empty, and another forum using the same BBCodes updated with no problems.

Ryan

User avatar
JoshyPHP
Code Contributor
Posts: 1058
Joined: Mon Jul 11, 2011 12:28 am

Re: phpBB 3.1.10 > 3.2.0 "Unterminated XPath Expression"

Post by JoshyPHP » Mon Apr 03, 2017 11:15 pm

Ok, those BBCodes don't seem to contain anything suspicious. I don't know what could trigger this error.

The only explanation I can come up with is that something somewhere uses { in an HTML attribute. Maybe an emoticon? Maybe an extension does something.
I wrote the thing that does BBCodes in 3.2.

Ryan JB
Registered User
Posts: 7
Joined: Sun Apr 02, 2017 4:08 pm

Re: phpBB 3.1.10 > 3.2.0 "Unterminated XPath Expression"

Post by Ryan JB » Mon Apr 03, 2017 11:39 pm

There are no extensions (the forum is vanilla, as I mentioned, and a fresh install of all files too) - there are some additional smileys installed, with various codes, but none using a "{" or "}" character in their code. And actually the smiley set is the same as the other forum mentioned, which had no problems with the update.

Is the database update process completely limited to accessing the database, as is implied? Or does it in any way interact with the file system?

If the former, I'll have a look at the databases for the two sites and see if I can spot what might be different between them. But if the update process actually interacts with the filesystem, then it could be a difference in server setup etc. perhaps?

Ryan

User avatar
JoshyPHP
Code Contributor
Posts: 1058
Joined: Mon Jul 11, 2011 12:28 am

Re: phpBB 3.1.10 > 3.2.0 "Unterminated XPath Expression"

Post by JoshyPHP » Tue Apr 04, 2017 12:07 am

I don't know about the update process, although I assume it does read and possibly write to the filesystem. That said, it doesn't matter. The only way to trigger this error that I can think of requires to have a { character somewhere in an HTML attribute used in markup/formatting: BBCodes, emoticons, something like that.
I wrote the thing that does BBCodes in 3.2.

Ryan JB
Registered User
Posts: 7
Joined: Sun Apr 02, 2017 4:08 pm

Re: phpBB 3.1.10 > 3.2.0 "Unterminated XPath Expression"

Post by Ryan JB » Tue Apr 04, 2017 5:01 pm

Solved!

So, I had some more time to look into this today: I put a little hack in place in the installer script to dump some more exact information on the variables currently in hand along with the error message, which revealed that the problem was caused (as you quite rightly suggested) by a smiley; not the "code" field, but the "emotion" description field, one of which had contained both a "{" and a "}", but which had presumably become truncated somehow by a past db update and now only had a "{", with no closing brace.

So, I fixed the broken smiley in the 3.1.10 admin interface and then re-ran the updater, which then quite happily updated the forum to v3.2.0 as hoped. :)

This does make me want to make a little suggestion to the development team, though (I think from your forum description that you're involved in developing the reparser functions, Josh?): firstly, perhaps it would be better if the updater was made more robust in future in dealing with fields containing unexpected characters like this? Or maybe, if characters can potentially cause problems like this for the software, perhaps it would be better to simply disallow them from the fields in question in the first place? I have to admit that I prefer the first option myself, as there are probably plenty of valid reasons to want to include a "{" character in a smiley code, or even other fields, and it really shouldn't break the forum software when this happens, ideally. Hope that's a helpful thought, anyway!

In any case, thanks again for the help and suggestions that clued me in to finding the problem. :)

Ryan

User avatar
JoshyPHP
Code Contributor
Posts: 1058
Joined: Mon Jul 11, 2011 12:28 am

Re: phpBB 3.1.10 > 3.2.0 "Unterminated XPath Expression"

Post by JoshyPHP » Tue Apr 04, 2017 11:20 pm

Glad you could fix that issue.

About making things "more robust", everything is a question of resource allocation. There's an infinite number of ways that things can go awry so it all depends on how easy it is for something bad to happen and how hard it is to prevent it. In your case, it's easy enough that I've already submitted a fix for the next 3.2 release. What it boils down to is that braces { or } need to be escaped (by doubling them, e.g. {{) otherwise they're interpreted as a dynamic template feature. Future versions will properly escape them transparently in smilies.

Parallel to that, lone braces will also be escaped automatically to mitigate potential issues.
I wrote the thing that does BBCodes in 3.2.

Post Reply

Return to “[3.2.x] Support Forum”