Skip to content

Commit

Permalink
Changes to be committed:
Browse files Browse the repository at this point in the history
	modified:   core/src/main/java/lucee/runtime/functions/string/REReplace.java
	modified:   core/src/main/java/lucee/runtime/functions/string/REReplaceNoCase.java

removed use of ThreadLocalPageContext.get() and replace with passed in pc
note: PageContext pc was already being passed but not used.
  • Loading branch information
penhorwood committed Sep 18, 2024
1 parent 166498e commit 4bb2fe6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
18 changes: 6 additions & 12 deletions core/src/main/java/lucee/runtime/functions/string/REReplace.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*
**/
/**
* Implements the CFML Function rereplace
Expand All @@ -23,7 +23,6 @@

import lucee.runtime.PageContext;
import lucee.runtime.PageContextImpl;
import lucee.runtime.engine.ThreadLocalPageContext;
import lucee.runtime.exp.FunctionException;
import lucee.runtime.exp.PageException;
import lucee.runtime.ext.function.BIF;
Expand All @@ -34,18 +33,13 @@ public final class REReplace extends BIF {

private static final long serialVersionUID = -1140669656936340678L;

public static String call(String string, String regExp, String replace) throws PageException { // MUST is this really needed?
Regex regex = ((PageContextImpl) ThreadLocalPageContext.get()).getRegex();
return regex.replace(string, regExp, replace, true, false);
}

public static String call(PageContext pc, String string, String regExp, String replace) throws PageException {
Regex regex = ((PageContextImpl) pc).getRegex();
return regex.replace(string, regExp, replace, true, false);
}

public static String call(PageContext pc, String string, String regExp, String replace, String scope) throws PageException {
Regex regex = ((PageContextImpl) ThreadLocalPageContext.get()).getRegex();
Regex regex = ((PageContextImpl) pc).getRegex();
if (scope.equalsIgnoreCase("all")) return regex.replaceAll(string, regExp, replace, true, false);
return regex.replace(string, regExp, replace, true, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*
**/
/**
* Implements the CFML Function rereplacenocase
Expand All @@ -23,7 +23,6 @@

import lucee.runtime.PageContext;
import lucee.runtime.PageContextImpl;
import lucee.runtime.engine.ThreadLocalPageContext;
import lucee.runtime.exp.FunctionException;
import lucee.runtime.exp.PageException;
import lucee.runtime.ext.function.BIF;
Expand All @@ -36,12 +35,12 @@ public final class REReplaceNoCase extends BIF implements Function {
private static final long serialVersionUID = 3261493342788819694L;

public static String call(PageContext pc, String string, String regExp, String replace) throws PageException {
Regex regex = ((PageContextImpl) ThreadLocalPageContext.get()).getRegex();
Regex regex = ((PageContextImpl) pc).getRegex();
return regex.replace(string, regExp, replace, false, false);
}

public static String call(PageContext pc, String string, String regExp, String replace, String scope) throws PageException {
Regex regex = ((PageContextImpl) ThreadLocalPageContext.get()).getRegex();
Regex regex = ((PageContextImpl) pc).getRegex();
if (scope.equalsIgnoreCase("all")) return regex.replaceAll(string, regExp, replace, false, false);
return regex.replace(string, regExp, replace, false, false);
}
Expand Down

0 comments on commit 4bb2fe6

Please sign in to comment.