Page 1 of 1

PHP Fatal error: Uncaught InvalidArgumentException: Cannot load XML: Extra content at the end of the document

Posted: Tue Sep 10, 2019 8:57 am
by bipolarmorgan
Main error received by php error log:

Code: Select all

PHP Fatal error:  Uncaught InvalidArgumentException: Cannot load XML: Extra content at the end of the document
 in /public_html/vendor/s9e/text-formatter/src/Renderer.php:23
Additional information in the error log:

Code: Select all

Stack trace:
#0 /public_html/vendor/s9e/text-formatter/src/Renderers/PHP.php(127): s9e\TextFormatter\Renderer->loadXML('<r><QUOTE autho...')
#1 /public_html/vendor/s9e/text-formatter/src/Renderer.php(31): s9e\TextFormatter\Renderers\PHP->renderRichText('<r><QUOTE autho...')
#2 /public_html/phpbb/textformatter/s9e/renderer.php(250): s9e\TextFormatter\Renderer->render('<r><QUOTE autho...')
#3 /public_html/includes/functions_content.php(600): phpbb\textformatter\s9e\renderer->render('<r><QUOTE autho...')
#4 /public_html/viewtopic.php(1732): generate_text_for_display('<r><QUOTE autho...', '1m8xy6t2', 'gA==', 3, true)
#5 {main}
  thrown in /public_html/vendor/s9e/text-formatter/src/Renderer.php on line 23
Can anyone help me pinpoint this issue?

I'm using phpBB 3.2.7, on php 7.2.22, using MySQL(i) 5.6.44

What other information would be helpful in diagnosing this error?

Thanks in advance!

Re: PHP Fatal error: Uncaught InvalidArgumentException: Cannot load XML: Extra content at the end of the document

Posted: Tue Sep 10, 2019 9:04 am
by warmweer
The first thing that comes to mind is that you could be using an outdated s9e extension. If it's the old (abandoned) s9e, it should be removed completely; if it's the more recent Media Embed, it's probably not the most recent version (viewtopic.php?f=616&t=2414716).

added: another possibility is an outdated Advanced BBCocde extension.
Which extensions are you using (and did this start after an update or after your host changed the php version?) (generally, when did this start?).

Re: PHP Fatal error: Uncaught InvalidArgumentException: Cannot load XML: Extra content at the end of the document

Posted: Tue Sep 10, 2019 11:26 am
by bipolarmorgan
Enabled Extensions:

Code: Select all

Advertisement Management	2.0.2	
Antispam by CleanTalk	5.7.1	
Ban Hammer	1.0.8	
Board Announcements	1.1.0	
Board Rules	2.1.1	
Mass Notification	1.0.4	
Pages	2.0.3	
phpBB Media Embed PlugIn	1.1.1	
Quoted where	1.0.3	
Search user topics	1.0.2	
Self delete	3.1.1	
Tapatalk Plugin for phpBB 3.1/3.2	2.1.3	
Thanks for posts	3.2.14	
User Merge   1.0.4
I'm using the latest media embed plugin, and isn't s9e builtin to phpBB? (it appears to reflect the same code as the stock 3.2.7 either way) Also, I don't have an advanced bbcode extension.

I did wonder if it had something to do with <br> getting replaced by just <r> somehow, but I can't figure out where to look. I did tons of google searches with no good results. If you have any other ideas, I'm open to suggestions. I am also willing to disable the media embed plugin if someone thinks that is the culprit.

The other weird thing is I have the same extensions on another forum and it's php error log isn't indicating this error.

And unfortunately I can't pinpoint any particular code changes that would relate to the errors I'm seeing, so I'm not sure other than a date of when it started and apparently it's been erroring for a while....

Re: PHP Fatal error: Uncaught InvalidArgumentException: Cannot load XML: Extra content at the end of the document

Posted: Tue Sep 10, 2019 12:25 pm
by 3Di
bipolarmorgan wrote:
Tue Sep 10, 2019 8:57 am
#4 /public_html/viewtopic.php(1732): generate_text_for_display('<r><QUOTE autho...', '1m8xy6t2', 'gA==', 3, true)
Ok, let's see.

In the POSTS_TABLE, you should search for

bbcode_uid = 1m8xy6t2
+
bbcode_bitfield = gA==

You should then be able to catch the culprit, the post which contains the wrong "text".

Remember, Extra content at the end of the document means that all what is AFTER the last </r> is outside of its scope, means you need to move it to the end of the text itself.

example

<r><QUOTE autho... my awesome text</r>this is extra content

should be

<r><QUOTE autho... my awesome text this is extra content</r>

Re: PHP Fatal error: Uncaught InvalidArgumentException: Cannot load XML: Extra content at the end of the document

Posted: Tue Sep 10, 2019 2:03 pm
by JoshyPHP
Agreed, the XML is the most important information at this stage. Assuming the forums use default settings, it can be retrieved via phpMyAdmin with this query:

Code: Select all

SELECT post_text FROM phpbb_posts WHERE bbcode_uid = '1m8xy6t2'

Re: PHP Fatal error: Uncaught InvalidArgumentException: Cannot load XML: Extra content at the end of the document

Posted: Tue Sep 10, 2019 3:27 pm
by bipolarmorgan
JoshyPHP wrote:
Tue Sep 10, 2019 2:03 pm
Agreed, the XML is the most important information at this stage. Assuming the forums use default settings, it can be retrieved via phpMyAdmin with this query:

Code: Select all

SELECT post_text FROM phpbb_posts WHERE bbcode_uid = '1m8xy6t2'
Agreed with both of you, here is my result...

Code: Select all

<r><QUOTE author="jordyl[emoji813]ves"><s>[quote="jordyl[emoji813]ves"]</s><QUOTE author="republique"><s>[quote="republique"]</s>I can't believe she's not still a virgin, peepler are dethperate.<e>[/quote]</e></QUOTE>

Don't listen to society, you don't have to be attractive to get dick.<e>[/quote]</e></QUOTE>

She doesn't particularly look human, let alone attractive lol</r>
I'm stumped as to where the <r> and <s> and <e> came from first of all and second, the emoji's are probably not supposed to be there either... correct me if I'm wrong, please.

Here's a second example (as I've had many of these errors show up in the past month or so...) -

Code: Select all

<r>[emoji615]️[emoji615]️[emoji615]️[emoji615]️[emoji615]️New thread here everyone <URL url="https://gurugossiper.com/viewtopic.php?f=141&amp;t=33457%5Bemoji615%5D%EF%B8%8F%5Bemoji615%5D%EF%B8%8F%5Bemoji615%5D%EF%B8%8F%5Bemoji615%5D%EF%B8%8F%5Bemoji615%5D%EF%B8%8F%5Bemoji615%5D%EF%B8%8F"><LINK_TEXT text="viewtopic.php?f=141&amp;t=33457[emoji615]️[ ... emoji615]️">https://gurugossiper.com/viewtopic.php?f=141&amp;t=33457[emoji615]️[emoji615]️[emoji615]️[emoji615]️[emoji615]️[emoji615]️</LINK_TEXT></URL><br/>
<br/>
Sent from my SM-G950F using Tapatalk</r>
Which in this case has the <r> wrapping the content and then emoji's sprinkled in... weird?

Re: PHP Fatal error: Uncaught InvalidArgumentException: Cannot load XML: Extra content at the end of the document

Posted: Tue Sep 10, 2019 4:31 pm
by JoshyPHP
The XML is fine. My guess is that Tapatalk is doing something that makes it invalid. The emoji are probably Tapatalk's own custom thing I suppose because emoji handling in phpBB doesn't look like this.

Disable Tapatalk, see if it fixes it then report it as a bug to the Tapatalk extension's maintainers.

Edit: I looked into Tapatalk and indeed it's related to their custom emoji. Edit the quote to remove the emoji from the user's name and it should work better.

Re: PHP Fatal error: Uncaught InvalidArgumentException: Cannot load XML: Extra content at the end of the document

Posted: Tue Sep 10, 2019 6:23 pm
by bipolarmorgan
JoshyPHP wrote:
Tue Sep 10, 2019 4:31 pm
The XML is fine. My guess is that Tapatalk is doing something that makes it invalid. The emoji are probably Tapatalk's own custom thing I suppose because emoji handling in phpBB doesn't look like this.

Disable Tapatalk, see if it fixes it then report it as a bug to the Tapatalk extension's maintainers.

Edit: I looked into Tapatalk and indeed it's related to their custom emoji. Edit the quote to remove the emoji from the user's name and it should work better.
Well, that helps greatly! I'll contact their support team regarding the bug. Thanks for the help guys!!

I will report back what I find out and provide info if I get it fixed.

EDIT: https://github.com/Naguissa/mobiquo_thanks/issues/2

Re: PHP Fatal error: Uncaught InvalidArgumentException: Cannot load XML: Extra content at the end of the document

Posted: Tue Sep 10, 2019 6:35 pm
by JoshyPHP
I've already posted a topic in their support forums: https://www.tapatalk.com/groups/tapatal ... 96&t=43975

The fix is trivial and you can edit your own files to get it fixed right now if you're confident enough.

Re: PHP Fatal error: Uncaught InvalidArgumentException: Cannot load XML: Extra content at the end of the document

Posted: Tue Sep 10, 2019 6:45 pm
by bipolarmorgan
JoshyPHP wrote:
Tue Sep 10, 2019 6:35 pm
I've already posted a topic in their support forums: https://www.tapatalk.com/groups/tapatal ... 96&t=43975

The fix is trivial and you can edit your own files to get it fixed right now if you're confident enough.
OH GREAT!! Now I don't even have to play the waiting game and explain myself all over again. I'll give that a go and report back. Thanks again JoshyPHP!

Re: PHP Fatal error: Uncaught InvalidArgumentException: Cannot load XML: Extra content at the end of the document

Posted: Tue Sep 10, 2019 6:50 pm
by JoshyPHP
It's in the topic over at Tapatalk's but here's the relevant part:
The fix is to replace line 446 of ext/tapatalk/tapatalk/event/main_listener.php:

Code: Select all

$message = preg_replace('/\[emoji(\d+)\]/i', '<IMG src="'.$protocol.'://emoji.tapatalk-cdn.com/emoji\1.png" />', $message);
...with this:

Code: Select all

$message = preg_replace('/\[emoji(\d+)\](?=[^<>]*+<(?!\\/CODE>))/i', '<IMG src="'.$protocol.'://emoji.tapatalk-cdn.com/emoji\1.png"/>', $message);

Re: PHP Fatal error: Uncaught InvalidArgumentException: Cannot load XML: Extra content at the end of the document

Posted: Tue Sep 10, 2019 10:34 pm
by bipolarmorgan
Haven't had an error since 15:59:38 UTC ... I'd say you found my problem, Thanks, it's very appreciated. :mrgreen: