Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 14, 2023. It is now read-only.
/ICEcoderPublic archive

Commit2a00f7e

Browse files
author
mattpass
committed
Regex simplification and not working with _perms
1 parentfcd2e51 commit2a00f7e

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

‎lib/multiple-results.php‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@
4949
let foundInSelected = false;
5050
const userTarget = parent.document.findAndReplace.target.value;
5151
const findText = parent.document.findAndReplace.find.value;
52-
const rExp = new RegExp(true === parent.ICEcoder.findRegex ? findText : parent.ICEcoder.escapeRegex(findText), "gi");
52+
const regexFindText = true === parent.ICEcoder.findRegex ? findText : parent.ICEcoder.escapeRegex(findText);
53+
const rExp = new RegExp("(" + regexFindText + ")", "gi");
5354
<?php
54-
$findText =str_replace("ICEcoder:","",str_replace("&#39;","\'",$_GET['find']));
5555
// Find in open docs?
5656
// TODO: This doesn't actually replace if using regex, it doesn't error - tabs show a change, but nothing replaced
5757
if (false ===isset($_GET['target'])) {
@@ -101,15 +101,15 @@
101101
haveMatch = true;
102102
}
103103
if (
104-
true === haveMatch && -1< targetURL.indexOf('_perms')) {
104+
true === haveMatch && -1=== targetURL.indexOf('_perms')) {
105105
if (-1 < userTarget.indexOf("selected")) {
106106
for (let j = 0; j < parent.ICEcoder.selectedFiles.length; j++) {
107107
if (
108-
// If the pipe delimited targetURL starts with this pipe delimited, non _perms elem selectedFile
109-
0 === targetURL.replace(/\//g, "|").indexOf(parent.ICEcoder.selectedFiles[j].replace(/\//g, "|").replace(/_perms/g, "").toLowerCase())
108+
// If the pipe delimited targetURL starts with this pipe delimited selectedFile
109+
0 === targetURL.replace(/\//g, "|").indexOf(parent.ICEcoder.selectedFiles[j].replace(/\//g, "|").toLowerCase())
110110
&& (
111-
// If the slash delimited, non _permselem matchesthe slasj delimited, non _perms elem
112-
targetURL.replace(/\|/g, "/").replace(/_perms/g, "")=== parent.ICEcoder.selectedFiles[j].replace(/\|/g, "/").replace(/_perms/g, "").toLowerCase()
111+
// If the slash delimitedelem matchesthis slash delimited elem
112+
targetURL.replace(/\|/g, "/")=== parent.ICEcoder.selectedFiles[j].replace(/\|/g, "/").toLowerCase()
113113
||
114114
// Path length for targetURL is greater than path length for this selectedFile and targetURL char at selectedFiles length ends with a slash
115115
(targetURL.replace(/\|/g, "/").split("/").length > parent.ICEcoder.selectedFiles[j].replace(/\|/g, "/").split("/").length && "/" === targetURL.charAt(parent.ICEcoder.selectedFiles[j].length)))) {
@@ -122,7 +122,7 @@
122122
if (-1 < targetURLElem.parentNode.parentNode.className.indexOf('pft-directory')) {
123123
continue;
124124
}
125-
const tidiedFileName = targetURLDisplay.replace(/\|/g, "/").replace(/_perms/g, "");
125+
const tidiedFileName = targetURLDisplay.replace(/\|/g, "/");
126126
resultsDisplay +=
127127
'<a href="#"diff-ef360d608b10214d3ebb7c67c0ee70e03ff661c50cce6bef43a85675bc3935a3-128-128-0" data-selected="false" role="gridcell" tabindex="-1" valign="top">128
128
tidiedFileName +
@@ -132,15 +132,14 @@
132132

133133

134134
// Highlight our matches in filename via single regex () capturing group to use with $1
135-
const re = /(<?phpechostr_replace("/","\/",xssClean($findText,'script'));?>)/gi;
136-
resultsDisplay += tidiedFileName.replace(re, '<b>$1</b>') + '</a><br>';
135+
resultsDisplay += tidiedFileName.replace(rExp, '<b>$1</b>') + '</a><br>';
137136

138137
// If replacing in filename
139138
<?phpif (true ===isset($_GET['replace'])) {?>
140139
resultsDisplay +=
141140
'<div id="foundCount' + i + '">' +
142141
'<?phpecho$t['rename to'];?> ' +
143-
tidiedFileName.replace(re, "<b><?php
142+
tidiedFileName.replace(rExp, "<b><?php
144143
if (isset($_GET['replace'])) {echostr_replace("&amp;","&",xssClean($_GET['replace'],'script'));};
145144
?></b>")+'</div>';
146145
<?php
@@ -214,6 +213,7 @@ function phpGrep($q, $path, $base) {
214213
}
215214

216215
// TODO: consider $findText here, is OK?
216+
$findText =str_replace("ICEcoder:","",str_replace("&#39;","\'",$_GET['find']));
217217
$results =phpGrep($findText,$docRoot .$iceRoot,$docRoot .$iceRoot);
218218
echo'resultsDisplay += "' .$results .'";';
219219
?>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp