You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
edk2toolext\environment\extdeptypes\nuget_dependency.py
line number: 172
self.nuget_cache_path = return_string.strip().strip("global-packages: ")
This is an incorrect usage of the strip method. This will cause failures if the nuget dependency path ends with "e"
For example if the NuGet cache path is: "C:\nuget_cache", the second strip method will return an invalid path.
The second strip("global-packages: ") call is intended to remove the characters in the set "global-packages: " from both ends of the string. This set includes each individual character: 'g', 'l', 'o', 'b', 'a', 'l', '-', 'p', 'a', 'c', 'k', 'a', 'g', 'e', 's', ':', and ' ' (space). It does not treat "global-packages: " as a single substring to remove.
This method then removes these characters from the beginning and the end of the string until it encounters a character not in the set. Since the string "C:\nuget_cache" does not start with any of those characters, the beginning of the string remains unchanged. However, the end of the string "C:\nuget_cache" ends with "e", which is in the set of characters to remove. Therefore, it removes "e" from the end, resulting in "C:\nuget_cach".
Contact Details
sanjeevinishanth@gmail.com
Describe the Bug
edk2toolext\environment\extdeptypes\nuget_dependency.py
line number: 172
self.nuget_cache_path = return_string.strip().strip("global-packages: ")
This is an incorrect usage of the strip method. This will cause failures if the nuget dependency path ends with "e"
For example if the NuGet cache path is: "C:\nuget_cache", the second strip method will return an invalid path.
The second strip("global-packages: ") call is intended to remove the characters in the set "global-packages: " from both ends of the string. This set includes each individual character: 'g', 'l', 'o', 'b', 'a', 'l', '-', 'p', 'a', 'c', 'k', 'a', 'g', 'e', 's', ':', and ' ' (space). It does not treat "global-packages: " as a single substring to remove.
This method then removes these characters from the beginning and the end of the string until it encounters a character not in the set. Since the string "C:\nuget_cache" does not start with any of those characters, the beginning of the string remains unchanged. However, the end of the string "C:\nuget_cache" ends with "e", which is in the set of characters to remove. Therefore, it removes "e" from the end, resulting in "C:\nuget_cach".
What Python version are you using?
Python 3.10, Python 3.11
Reproduction steps
When I modified the default NUGET cache path.
Expected behavior
For the right NuGet cache path to be found
Execution Environment
Windows
ENV_VARIABLE:
NUGET_PACKAGES="C:\nuget_cache"
Pip packages
edk2-pytool-library~=0.20.0
edk2-pytool-extensions~=0.27.2
Additional context
No response
The text was updated successfully, but these errors were encountered: