From cda63d33d7a874f082ce4b3f340e80e99ea90e17 Mon Sep 17 00:00:00 2001
From: Tim Steiner <tsteiner2@unl.edu>
Date: Thu, 16 Sep 2010 17:08:27 +0000
Subject: [PATCH] Prevent an infinite loop in the migration tool.

git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x@169 20a16fea-79d4-4915-8869-1ea9d5ebf173
---
 sites/all/modules/unl/unl_migration.php | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sites/all/modules/unl/unl_migration.php b/sites/all/modules/unl/unl_migration.php
index 2f157ec6..14eacf95 100644
--- a/sites/all/modules/unl/unl_migration.php
+++ b/sites/all/modules/unl/unl_migration.php
@@ -477,8 +477,12 @@ class Unl_Migration_Tool
             while (strpos($parts['path'], '/./') !== FALSE) {
                 $parts['path'] = strtr($parts['path'], array('/./', '/'));
             }
+            $i = 0;
             while (strpos($parts['path'], '/../') !== FALSE) {
                 $parts['path'] = preg_replace('/\\/[^\\/]*\\/\\.\\.\\//', '/', $parts['path']);
+                $parts['path'] = preg_replace('/^\\/\\.\\.\\//', '/', $parts['path']);
+                // Prevent infinite loops if we get some crazy url.
+                if ($i++ > 100) exit;
             }
         }
         
-- 
GitLab