|
101 | 101 | haveMatch = true;
|
102 | 102 | }
|
103 | 103 | if (
|
104 |
| - // TODO: Find in filenames not working with regex, see all instances of findText and $findText below |
105 | 104 | true === haveMatch && -1 < targetURL.indexOf('_perms')) {
|
106 | 105 | if (-1 < userTarget.indexOf("selected")) {
|
107 | 106 | for (let j = 0; j < parent.ICEcoder.selectedFiles.length; j++) {
|
|
123 | 122 | if (-1 < targetURLElem.parentNode.parentNode.className.indexOf('pft-directory')) {
|
124 | 123 | continue;
|
125 | 124 | }
|
| 125 | + const tidiedFileName = targetURLDisplay.replace(/\|/g, "/").replace(/_perms/g, ""); |
126 | 126 | resultsDisplay +=
|
127 | 127 | '<a href="javascript:parent.ICEcoder.openFile(\'<?php echo $docRoot;?>' +
|
128 |
| - targetURLDisplay.replace(/\|/g, "/").replace(/_perms/g,"") + |
| 128 | + tidiedFileName + |
129 | 129 | '\');parent.ICEcoder.goFindAfterOpenInt = setInterval(function(){goFindAfterOpen(\'<?php echo $docRoot;?>' +
|
130 |
| - targetURLDisplay.replace(/\|/g, "/").replace(/_perms/g, "") + |
| 130 | + tidiedFileName + |
131 | 131 | '\')}, 20);parent.ICEcoder.showHide(\'hide\', parent.document.getElementById(\'blackMask\'))">';
|
132 |
| - // TODO: get this line working |
133 |
| - resultsDisplay += |
134 |
| - targetURLDisplay.replace(/\|/g, "/").replace(/_perms/g, "").replace(/<?php |
135 |
| - echo str_replace("/", "\/",strtolower(preg_quote($findText))); ?>/g, "<b>" + |
136 |
| - parent.ICEcoder.xssClean(findText).toLowerCase() + "</b>"); |
137 |
| - resultsDisplay += '</a><br>'; |
| 132 | + |
| 133 | + |
| 134 | + // Highlight our matches in filename via single regex () capturing group to use with $1 |
| 135 | + const re = /(<?php echo str_replace("/", "\/",xssClean($findText, 'script')); ?>)/gi; |
| 136 | + resultsDisplay += tidiedFileName.replace(re, '<b>$1</b>') + '</a><br>'; |
| 137 | + |
| 138 | + // If replacing in filename |
138 | 139 | <?php if (true === isset($_GET['replace'])) { ?>
|
139 | 140 | resultsDisplay +=
|
140 | 141 | '<div id="foundCount' + i + '">' +
|
141 | 142 | '<?php echo $t['rename to'];?> ' +
|
142 |
| - targetURL.replace(/\|/g, "/").replace(/_perms/g, "").replace(/<?php echo str_replace("/", "\/",strtolower(preg_quote($findText))); ?>/g,"<b><?php |
| 143 | + tidiedFileName.replace(re, "<b><?php |
143 | 144 | if (isset($_GET['replace'])) {echo str_replace("&", "&", xssClean($_GET['replace'], 'script'));};
|
144 | 145 | ?></b>")+'</div>';
|
145 | 146 | <?php
|
@@ -178,7 +179,7 @@ function phpGrep($q, $path, $base) {
|
178 | 179 | }
|
179 | 180 | // Exclude the dirs/files we wish to exclude from find & replace tasks (string in path name)
|
180 | 181 | for ($i = 0; $i < count($ICEcoder['findFilesExclude']); $i++) {
|
181 |
| - if (false !== strpos($fullpath, str_replace("*", "", $ICEcoder['findFilesExclude'][$i]))) { |
| 182 | + if (false !== strpos($fullPath, str_replace("*", "", $ICEcoder['findFilesExclude'][$i]))) { |
182 | 183 | $bFile = true;
|
183 | 184 | };
|
184 | 185 | }
|
@@ -234,7 +235,7 @@ function phpGrep($q, $path, $base) {
|
234 | 235 | targetName = "<?php echo $targetName;?>";
|
235 | 236 | selectedText = foundInSelected ? "<?php echo $t['selected'];?> " : "";
|
236 | 237 | document.getElementById('title').innerHTML =
|
237 |
| - findText.replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, """).replace(/'/g, "'") + |
| 238 | + parent.ICEcoder.xssClean(findText) + |
238 | 239 | " <?php echo $t['found in'];?> " + foundArray.length + " " + selectedText + targetName + plural;
|
239 | 240 | document.getElementById('results').innerHTML = resultsDisplay;
|
240 | 241 |
|
|
0 commit comments