Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function List: Not all functions listed for a php file #13643

Open
golgoth1009 opened this issue May 11, 2023 · 2 comments
Open

Function List: Not all functions listed for a php file #13643

golgoth1009 opened this issue May 11, 2023 · 2 comments

Comments

@golgoth1009
Copy link

Description of the Issue

Using a php class file containing a lot of functions (around 188 functions),
some functions are present, some are missing in the list
I provide a PHP file as exemple (renamed to txt for the upload)

Steps to Reproduce the Issue

  1. Load the file
  2. Show the Function List
  3. Look for isAbsPath(). This function will be missing in the list.
  4. Then also functions following this one are missing

Expected Behavior

Have all the functions in the list

Actual Behavior

All functions after validPathStr() are missing

Debug Information

Notepad++ v8.5.2 (64-bit)
Build time : Apr 4 2023 - 19:55:32
Path : C:\Program Files\Notepad++\notepad++.exe
Command Line :
Admin mode : OFF
Local Conf mode : OFF
Cloud Config : OFF
OS Name : Windows 10 Pro N (64-bit)
OS Version : 21H2
OS Build : 19044.2846
Current ANSI codepage : 1252
Plugins :
AnalysePlugin (1.13.49)
CodeAlignmentNpp (14.1.107)
ComparePlugin (2.0.2)
HTMLTag (1.3.5)
mimeTools (2.9)
Npp-Highlighter (1.0.0.1)
NppConverter (4.5)
NppExport (0.4)
NPPJSONViewer (2.0.4)
NppTaskList (2.5)
NppXmlTreeviewPlugin (2)
XMLTools (3.1.1.13)

class.t3lib_div.txt

@vlakoff
Copy link
Contributor

vlakoff commented Feb 3, 2024

I tried this, and could not reproduce the issue. All functions are listed. (Notepad++ 8.6.2 32-bit)

Might be related: #14208. Ping @elmonty.
It would be interesting if you guys could try each other's testcase and see if you also encounter their bug.

@elmonty
Copy link

elmonty commented Feb 4, 2024

I can reproduce this behavior with the given file. If I remove all curly braces from the body of the function validPathStr(), then all the functions appear in the function list. Even though the original version of the function is perfectly good and valid PHP, the following version of the function causes all functions to appear in the function list:

public static function validPathStr($theFile) {
	if (strpos($theFile, '//') === FALSE && strpos($theFile, '\\') === FALSE && !preg_match('#(?:^\.\.|/\.\./|[[:cntrl:]])#u', $theFile))
		return TRUE;
	
	return FALSE;
}

At first, I suspected that the regular expression might be causing the issue, but removing just that condition alone did not solve the problem. The version of the function below still shows the issue where the remaining functions do not appear in the function list:

public static function validPathStr($theFile) {
	if (strpos($theFile, '//') === FALSE && strpos($theFile, '\\') === FALSE) {
		return TRUE;
	}

	return FALSE;
}

If I take the original version of the function and change the double slash in the string literal to a simple alphabetic character, all functions then appear in the function list:

public static function validPathStr($theFile) {
	if (strpos($theFile, 'x') === FALSE && strpos($theFile, '\\') === FALSE && !preg_match('#(?:^\.\.|/\.\./|[[:cntrl:]])#u', $theFile)) {
		return TRUE;
	}

	return FALSE;
}

So, either removing the curly braces or replacing the double slash causes the issue to disappear.

The following version of the code can be used as workaround until this bug is squashed. If you prefer, you can do the same for the double backslash to be consistent.

public static function validPathStr($theFile) {
	$DOUBLE_SLASH = '//';

	if (strpos($theFile, $DOUBLE_SLASH) === FALSE && strpos($theFile, '\\') === FALSE && !preg_match('#(?:^\.\.|/\.\./|[[:cntrl:]])#u', $theFile)) {
		return TRUE;
	}

	return FALSE;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants