Fixed bug #8205: Shortcut ends in parse_url-error
authorSteffen Kamper <info@sk-typo3.de>
Mon, 29 Dec 2008 13:53:48 +0000 (13:53 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Mon, 29 Dec 2008 13:53:48 +0000 (13:53 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/branches/TYPO3_4-2@4623 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_clipboard.php
typo3/alt_clickmenu.php
typo3/alt_shortcut.php
typo3/backend.php
typo3/class.alt_menu_functions.inc
typo3/classes/class.modulemenu.php
typo3/classes/class.shortcutmenu.php
typo3/js/backendsearch.js
typo3/js/workspaces.js

index 9fe4f74..616d61c 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2008-12-28  Steffen Kamper  <info@sk-typo3.de> 
 
        * Fixed bug #9773: Fallback for skinImg having forceFileExtension
+       * Fixed bug #8205: Shortcut ends in parse_url-error
 
 2008-12-25  Dmitry Dulepov  <dmitry@typo3.org>
 
index 8542df2..2995587 100755 (executable)
@@ -338,18 +338,18 @@ class t3lib_clipboard {
                }
                                // Edit:
                if (!$this->fileMode && $elCount)       {
-                       $opt[]='<option value="'.htmlspecialchars("window.location.href='".$this->editUrl()."&returnUrl='+top.rawurlencode(window.location.href);").'">'.$this->clLabel('edit','rm').'</option>';
+                       $opt[]='<option value="' . htmlspecialchars("window.location.href='" . $this->editUrl() . "&returnUrl='+top.rawurlencodeAndRemoveSiteUrl(window.location.href);") . '">' . $this->clLabel('edit', 'rm') . '</option>';
                }
                                // Delete:
                if ($elCount)   {
                        if($GLOBALS['BE_USER']->jsConfirmation(4))      {
                                $js = "
                        if(confirm(".$GLOBALS['LANG']->JScharCode(sprintf($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.deleteClip'),$elCount)).")){
-                               window.location.href='".$this->deleteUrl(0,$this->fileMode?1:0)."&redirect='+top.rawurlencode(window.location.href);
+                               window.location.href='" . $this->deleteUrl(0, $this->fileMode ? 1 : 0) . "&redirect='+top.rawurlencodeAndRemoveSiteUrl(window.location.href);
                        }
                                        ";
                        } else {
-                               $js = " window.location.href='".$this->deleteUrl(0,$this->fileMode?1:0)."&redirect='+top.rawurlencode(window.location.href); ";
+                               $js = " window.location.href='" . $this->deleteUrl(0, $this->fileMode ? 1 : 0) . "&redirect='+top.rawurlencodeAndRemoveSiteUrl(window.location.href); ";
                        }
                        $opt[]='<option value="'.htmlspecialchars($js).'">'.$this->clLabel('delete','rm').'</option>';
                }
index a03ef56..1d66519 100755 (executable)
@@ -425,7 +425,7 @@ class clickMenu {
        function urlRefForCM($url,$retUrl='',$hideCM=1,$overrideLoc='') {
                $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
                $editOnClick= ($overrideLoc ? 'var docRef='.$overrideLoc : 'var docRef=(top.content.list_frame)?top.content.list_frame:'.$loc).'; docRef.location.href=top.TS.PATH_typo3+\''.$url.'\''.
-                       ($retUrl?"+'&".$retUrl."='+top.rawurlencode(".$this->frameLocation('docRef.document').')':'').';'.
+                       ($retUrl ? "+'&" . $retUrl . "='+top.rawurlencodeAndRemoveSiteUrl(" . $this->frameLocation('docRef.document') . ')' :'') . ';' .
                        ($hideCM?'return hideCM();':'');
                return $editOnClick;
        }
@@ -476,7 +476,7 @@ class clickMenu {
                } else {
                        $conf = $loc;
                }
-               $editOnClick = 'if('.$conf.'){'.$loc.'.location.href=top.TS.PATH_typo3+\''.$this->clipObj->pasteUrl($table,$uid,0).'&redirect=\'+top.rawurlencode('.$this->frameLocation($loc.'.document').'); hideCM();}';
+               $editOnClick = 'if(' . $conf . '){' . $loc . '.location.href=top.TS.PATH_typo3+\'' . $this->clipObj->pasteUrl($table, $uid, 0) . '&redirect=\'+top.rawurlencodeAndRemoveSiteUrl(' . $this->frameLocation($loc . '.document') . '); hideCM();}';
 
                return $this->linkItem(
                        $this->label('paste'.$type),
@@ -678,11 +678,11 @@ class clickMenu {
                        if ($BE_USER->uc['classicPageEditMode'] || !t3lib_extMgm::isLoaded('cms'))      {
                                $addParam='&editRegularContentFromId='.intval($this->iParts[1]);
                        } else {
-                               $editOnClick="top.fsMod.recentIds['web']=".intval($this->iParts[1]).";top.goToModule('".$pageModule."',1);";
+                               $editOnClick='if(' . $loc . '){' . $loc . ".location.href=top.TS.PATH_typo3+'alt_doc.php?returnUrl='+top.rawurlencodeAndRemoveSiteUrl(" . $this->frameLocation($loc . '.document') . ")+'&edit[".$table."][".$uid."]=edit".$addParam."';}";
                        }
                }
                if (!$editOnClick)      {
-                       $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'alt_doc.php?returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'&edit[".$table."][".$uid."]=edit".$addParam."';}";
+                       $editOnClick='if(' . $loc . '){' . $loc . ".location.href=top.TS.PATH_typo3+'alt_doc.php?returnUrl='+top.rawurlencodeAndRemoveSiteUrl(" . $this->frameLocation($loc . '.document') . ")+'&edit[".$table."][".$uid."]=edit".$addParam."';}";
                }
 
                return $this->linkItem(
@@ -705,7 +705,7 @@ class clickMenu {
                $loc='top.content'.(!$this->alwaysContentFrame?'.list_frame':'');
                $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'".
                        ($this->listFrame?
-                               "alt_doc.php?returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'&edit[".$table."][-".$uid."]=new'":
+                               "alt_doc.php?returnUrl='+top.rawurlencodeAndRemoveSiteUrl(" . $this->frameLocation($loc . '.document') . ")+'&edit[".$table."][-".$uid."]=new'":
                                'db_new.php?id='.intval($uid)."'").
                        ';}';
 
@@ -733,7 +733,7 @@ class clickMenu {
                } else {
                        $conf = '1==1';
                }
-               $editOnClick='if('.$loc." && ".$conf." ){".$loc.".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
+               $editOnClick = 'if(' . $loc . " && " . $conf . " ){" . $loc . ".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencodeAndRemoveSiteUrl(" . $this->frameLocation($loc . '.document') . ")+'".
                        "&cmd[".$table.']['.$uid.'][delete]=1&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
 
                return $this->linkItem(
@@ -802,7 +802,7 @@ class clickMenu {
            $uid = $rec['_ORIG_uid'] ? $rec['_ORIG_uid'] : $rec['uid'];
            $editOnClick='';
            $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
-           $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
+           $editOnClick = 'if(' . $loc . '){' . $loc . ".location.href=top.TS.PATH_typo3+'tce_db.php?redirect='+top.rawurlencodeAndRemoveSiteUrl(" . $this->frameLocation($loc . '.document') . ")+'" .
                "&data[".$table.']['.$uid.']['.$flagField.']='.($rec[$flagField]?0:1).'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
 
            return $this->linkItem(
@@ -914,7 +914,7 @@ class clickMenu {
        function FILE_launch($path,$script,$type,$image,$noReturnUrl=FALSE)     {
                $loc='top.content'.(!$this->alwaysContentFrame?'.list_frame':'');
 
-               $editOnClick='if('.$loc.'){'.$loc.".location.href=top.TS.PATH_typo3+'".$script.'?target='.rawurlencode($path).($noReturnUrl ? "'" : "&returnUrl='+top.rawurlencode(".$this->frameLocation($loc.'.document').")").";}";
+               $editOnClick = 'if(' . $loc . '){' . $loc . ".location.href=top.TS.PATH_typo3+'".$script.'?target=' . rawurlencode($path) . ($noReturnUrl ? "'" : "&returnUrl='+top.rawurlencodeAndRemoveSiteUrl(" . $this->frameLocation($loc . '.document') . ")") . ";}";
 
                return $this->linkItem(
                        $this->label($type),
@@ -965,7 +965,7 @@ class clickMenu {
                } else {
                        $conf = '1==1';
                }
-               $editOnClick='if('.$loc." && ".$conf." ){".$loc.".location.href=top.TS.PATH_typo3+'tce_file.php?redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').")+'".
+               $editOnClick = 'if(' . $loc . " && " . $conf . " ){" . $loc . ".location.href=top.TS.PATH_typo3+'tce_file.php?redirect='+top.rawurlencodeAndRemoveSiteUrl(" . $this->frameLocation($loc . '.document') . ")+'" .
                        "&file[delete][0][data]=".rawurlencode($path).'&vC='.$GLOBALS['BE_USER']->veriCode()."';hideCM();}";
 
                return $this->linkItem(
@@ -994,7 +994,7 @@ class clickMenu {
                }
 
                $editOnClick='if('.$conf.'){'.$loc.".location.href=top.TS.PATH_typo3+'".$this->clipObj->pasteUrl('_FILE',$path,0).
-                       "&redirect='+top.rawurlencode(".$this->frameLocation($loc.'.document').'); hideCM();}';
+                       "&redirect='+top.rawurlencodeAndRemoveSiteUrl(" . $this->frameLocation($loc . '.document') .'); hideCM();}';
 
                return $this->linkItem(
                        $this->label('pasteinto'),
@@ -1082,7 +1082,7 @@ class clickMenu {
                $negativeSign = ($into == 'into') ? '' : '-';
                $editOnClick='';
                $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
-               $editOnClick='if('.$loc.'){'.$loc.'.document.location=top.TS.PATH_typo3+"tce_db.php?redirect="+top.rawurlencode('.$this->frameLocation($loc.'.document').')+"'.
+               $editOnClick = 'if(' . $loc . '){' . $loc . '.document.location=top.TS.PATH_typo3+"tce_db.php?redirect="+top.rawurlencodeAndRemoveSiteUrl(' . $this->frameLocation($loc . '.document') . ')+"' .
                        '&cmd[pages]['.$srcUid.']['.$action.']='.$negativeSign.$dstUid.'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode().'";hideCM();}';
 
                return $this->linkItem(
@@ -1106,7 +1106,7 @@ class clickMenu {
        function dragDrop_copymovefolder($srcPath,$dstPath,$action)     {
                $editOnClick='';
                $loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
-               $editOnClick='if('.$loc.'){'.$loc.'.document.location=top.TS.PATH_typo3+"tce_file.php?redirect="+top.rawurlencode('.$this->frameLocation($loc.'.document').')+"'.
+               $editOnClick = 'if(' . $loc . '){' . $loc . '.document.location=top.TS.PATH_typo3+"tce_file.php?redirect="+top.rawurlencodeAndRemoveSiteUrl(' . $this->frameLocation($loc . '.document') .')+"' .
                        '&file['.$action.'][0][data]='.$srcPath.'&file['.$action.'][0][target]='.$dstPath.'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode().'";hideCM();}';
 
                return $this->linkItem(
index da00b0e..44a52aa 100755 (executable)
@@ -168,7 +168,7 @@ class SC_alt_shortcut {
                $url = urldecode($this->URL);
 
                        // Lookup the title of this page and use it as default description
-               $page_id = $this->getLinkedPageId($url);
+               $page_id = $this->getLinkedPageId($url);         
                if (t3lib_div::testInt($page_id))       {
                        if (preg_match('/\&edit\[(.*)\]\[(.*)\]=edit/',$url,$matches))  {
                                        // Edit record
@@ -267,10 +267,10 @@ class SC_alt_shortcut {
                                window.location.href="alt_shortcut.php?editShortcut="+uid;
                        }
                        function submitEditPage(id)     {       //
-                               window.location.href="alt_shortcut.php?editPage="+top.rawurlencode(id);
+                               window.location.href="alt_shortcut.php?editPage="+top.rawurlencodeAndRemoveSiteUrl(id);
                        }
                        function changeWorkspace(workspaceId)   {       //
-                               window.location.href="alt_shortcut.php?changeWorkspace="+top.rawurlencode(workspaceId);
+                               window.location.href="alt_shortcut.php?changeWorkspace="+top.rawurlencodeAndRemoveSiteUrl(workspaceId);
                        }
                        function changeWorkspacePreview(newstate)       {       //
                                window.location.href="alt_shortcut.php?changeWorkspacePreview="+newstate;
index d2f2c3f..b56fd47 100644 (file)
@@ -337,7 +337,7 @@ class TYPO3backend {
        /**
         * Function similar to PHPs  rawurlencode();
         */
-       function rawurlencode(str)      {       //
+       function rawurlencode(str) {    //
                var output = escape(str);
                output = str_replace("*","%2A", output);
                output = str_replace("+","%2B", output);
@@ -347,6 +347,14 @@ class TYPO3backend {
        }
 
        /**
+        * Function to similar to PHPs  rawurlencode() which removes TYPO3_SITE_URL;
+        */
+       function rawurlencodeAndRemoveSiteUrl(str)      {       //
+               var siteUrl = "' . t3lib_div::getIndpEnv('TYPO3_SITE_URL') . '";
+               return rawurlencode(str_replace(siteUrl, \'\', str));
+       }
+       
+       /**
         * String-replace function
         */
        function str_replace(match,replace,string)      {       //
index 869f6f1..c45e954 100755 (executable)
@@ -288,7 +288,7 @@ class alt_menu_functions {
 
                                                // Setting additional JavaScript if frameset script:
                                        $addJS = '';
-                                       if ($moduleInfo['navFrameScript'])      {$addJS="+'&id='+top.rawurlencode(top.fsMod.recentIds['".$moduleName."'])";}
+                                       if ($moduleInfo['navFrameScript'])      {$addJS = "+'&id='+top.rawurlencodeAndRemoveSiteUrl(top.fsMod.recentIds['" . $moduleName . "'])";}
 
                                                // If there is a script to link to (and linking is not disabled.
                                        if ($link && !$dontLink)        {
index 8905ee9..89b491f 100644 (file)
@@ -198,7 +198,7 @@ class ModuleMenu {
                        $additionalJavascript = '';
                        if($moduleData['parentNavigationFrameScript']) {
                                $parentModuleName     = substr($moduleData['name'], 0, strpos($moduleData['name'], '_'));
-                               $additionalJavascript = "+'&id='+top.rawurlencode(top.fsMod.recentIds['".$parentModuleName."'])";
+                               $additionalJavascript = "+'&id='+top.rawurlencodeAndRemoveSiteUrl(top.fsMod.recentIds['" . $parentModuleName . "'])";
                        }
 
                        if($moduleData['link'] && $this->linkModules) {
@@ -413,7 +413,7 @@ class ModuleMenu {
                                                // Setting additional JavaScript if frameset script:
                                        $additionalJavascript = '';
                                        if($subModuleData['parentNavigationFrameScript']) {
-                                               $additionalJavascript = "+'&id='+top.rawurlencode(top.fsMod.recentIds['".$parentModuleName."'])";
+                                               $additionalJavascript = "+'&id='+top.rawurlencodeAndRemoveSiteUrl(top.fsMod.recentIds['" . $parentModuleName . "'])";
                                        }
 
                                        if($subModuleData['link'] && $this->linkModules) {
@@ -433,7 +433,7 @@ class ModuleMenu {
                                                }
 
                                                if(!$GLOBALS['BE_USER']->uc['condensedMode'] && $subModuleData['parentNavigationFrameScript']) {
-                                                       $additionalJavascript = "+'&id='+top.rawurlencode(top.fsMod.recentIds['".$parentModuleName."'])";
+                                                       $additionalJavascript = "+'&id='+top.rawurlencodeAndRemoveSiteUrl(top.fsMod.recentIds['" . $parentModuleName . "'])";
 
                                                        $submoduleNavigationFrameScript = $subModuleData['navigationFrameScript'] ? $subModuleData['navigationFrameScript'] : $subModuleData['parentNavigationFrameScript'];
                                                        $submoduleNavigationFrameScript = t3lib_div::resolveBackPath($submoduleNavigationFrameScript);
index e797004..8e04053 100644 (file)
@@ -493,7 +493,7 @@ class ShortcutMenu implements backend_toolbarItem {
                $shortcutName        = 'Shortcut'; // default name
                $shortcutNamePrepend = '';
 
-               $url             = urldecode(t3lib_div::_POST('url'));
+               $url             = t3lib_div::_POST('url');      
                $module          = t3lib_div::_POST('module');
                $motherModule    = t3lib_div::_POST('motherModName');
 
@@ -517,7 +517,7 @@ class ShortcutMenu implements backend_toolbarItem {
                }
 
                        // Lookup the title of this page and use it as default description
-               $pageId = $this->getLinkedPageId($url);
+               $pageId = $shortcut['recordid'] ? $shortcut['recordid'] : $this->getLinkedPageId($url);
 
                if(t3lib_div::testInt($pageId)) {
                        $page = t3lib_BEfunc::getRecord('pages', $pageId);
@@ -530,11 +530,12 @@ class ShortcutMenu implements backend_toolbarItem {
                                }
                        }
                } else {
-                       if (preg_match('/\/$/', $pageId))       {
+                       $dirName = urldecode($pageId);         
+                       if (preg_match('/\/$/', $dirName)) {
                                        // if $pageId is a string and ends with a slash,
                                        // assume it is a fileadmin reference and set
                                        // the description to the basename of that path
-                               $shortcutName .= basename($pageId);
+                               $shortcutName .= ' ' . basename($dirName);
                        }
                }
 
index 4643f2b..b9b6113 100644 (file)
@@ -123,7 +123,7 @@ var BackendSearch = Class.create({
         * calls the actual clear cache URL using an asynchronious HTTP request
         */
        invokeSearch: function() {
-               new Ajax.Request('alt_shortcut.php?ajax=1&editPage=' + top.rawurlencode($F('search-query')), {
+               new Ajax.Request('alt_shortcut.php?ajax=1&editPage=' + top.rawurlencodeAndRemoveSiteUrl($F('search-query')), {
                        method: 'get',
                        requestHeaders: {Accept: 'application/json'},
                        onSuccess: function(transport) {
index 17480cd..6cc7c6d 100644 (file)
@@ -28,9 +28,9 @@
 
 
 function changeWorkspace(workspaceId) {
-       window.location.href = 'backend.php?changeWorkspace=' + top.rawurlencode(workspaceId);
+       window.location.href = 'backend.php?changeWorkspace=' + top.rawurlencodeAndRemoveSiteUrl(workspaceId);
 }
 
 function changeWorkspacePreview(newstate) {
        window.location.href = 'backend.php?changeWorkspacePreview=' + newstate;
-}
\ No newline at end of file
+}