Fixed Nested quotes import problem

imthebest

Well-known member
I'm migrating from vB 3.8. One of my posts contains this:

Code:
[quote=user1][quote=user2;3142018]what user2 said[/quote]
what user1 said[/quote]

But xenForo is importing the nested quotes bad:

Code:
[quote="user1][quote=user2, post: 3142018"]what user2 said[/quote]
what user1 said[/quote]

Is this a bug?
 
@Super120

I am seeing a possible bug here.

library/XenForo/Importer/vBulletin.php

Code:
					if (stripos($post['pagetext'], '[quote=') !== false)
					{
						if (preg_match_all('/\[quote=("|\'|)(?P<username>[^;]*);\s*(?P<postid>\d+)\s*\1\]/siU', $post['pagetext'], $quotes, PREG_SET_ORDER))
						{
							$post['quotes'] = array();

							foreach ($quotes AS $quote)
							{
								$quotedPostId = intval($quote['postid']);

								$quotedPostIds[] = $quotedPostId;

								$post['quotes'][$quote[0]] = array($quote['username'], $quotedPostId);
							}
						}
					}

This piece specifically:

Code:
(?P<username>[^;]*)

Try changing it to this:

Code:
(?P<username>[^;\]]*)

The original code is bounds-matching the name with a semicolon only which would overrun in your example. The new code adds a right bracket to the bound so it can't escape from the first quote tag.

Moving to bugs for dev review. In the meantime please try that fix and re-run the import. Let me know if it works.
 
The fix seems reasonable -- it's certainly safer in that it's less likely to "over write", but has the potential to not rewrite something it potentially should.
 
Top Bottom