Open Daniheee opened 1 month ago
if (!bValidFilePath || (strFile[0] != '@' && strFile[0] != ':'))
{
bIsRawData = strFile.find("\n") != std::string::npos;
if (!bIsRawData)
{
bIsRawData = (strFile.find("technique ") != std::string::npos) && (strFile.find("pass ") != std::string::npos) &&
(strFile.find('{') != std::string::npos) && (strFile.find('}') != std::string::npos);
}
}
Maybe it should not check for an end line 😆
That's how you check for a match from find
- std::string::npos
is -1, find
returns -1 when no match is found.
If you're referring to the \n
check, that's because a filename wouldn't have a newline, therefore it has to be raw data.
I think the solution here is to remove the checks for technique
and pass
entirely. You can't have curly braces in a Windows filename so there's no clash possible when curly braces are being checked to determine if it's raw data or not.
That's how you check for a match from
find
-std::string::npos
is -1,find
returns -1 when no match is found.If you're referring to the
\n
check, that's because a filename wouldn't have a newline, therefore it has to be raw data.I think the solution here is to remove the checks for
technique
andpass
entirely. You can't have curly braces in a Windows filename so there's no clash possible when curly braces are being checked to determine if it's raw data or not.
Raw data can also not have new line as shown above. Thats not an ideal solution. You also can have curly braces and semicolons in windows filenames
Raw data can have newlines. The author says the first example works, and I've also done it myself before.
You also can have curly braces and semicolons in windows filenames
Yeah true for some reason I thought they weren't allowed. Anyway, I think it's unlikely someone tries to load a shader with filename containing technique
+ pass
+ {
+ }
What is to stop them currently having a filename called technique pass { }
anyway, makes sense to just remove the spaces from the find
imo.
cant we just have it all under one if statement?
bIsRawData = strFile.find("\n") != std::string::npos || (strFile.find("technique ") != std::string::npos
&& strFile.find("pass ") != std::string::npos && strFile.find('{') != std::string::npos
&& strFile.find('}') != std::string::npos);
Sounds fine, but you'll want to remove the spaces from technique
and pass
to resolve the author's issue.
cant we just have it all under one if statement?
bIsRawData = strFile.find("\n") != std::string::npos || (strFile.find("technique ") != std::string::npos && strFile.find("pass ") != std::string::npos && strFile.find('{') != std::string::npos && strFile.find('}') != std::string::npos);
Wouldn't finding for { and } be enough to identify raw data instead of path?
Wouldn't finding for { and } be enough to identify raw data instead of path?
{}.txt
is a valid file name. If {}.txt
is a valid file name then {}
is also a valid file name. You can see the issue here.
The best way would be to introduce a boolean flag isRawData
and then parse the shader according to that.
My bad I didn't realize file names can have {}
Describe the bug
So this is the main script, it obviously runs:
And if you remove the unnecessary whitespaces, it will still run perfectly:
But if you remove the extra whitespaces after the word 'technique' or 'pass,' it will throw a 'file doesn't exist' error:
OR
However, if you remove every whitespace, even after 'technique' and 'pass', it can still run, if you use it in a single line like this:
This way the shader will be created again without any problem.
Steps to reproduce
Version
Client: v1.6-release-22780 (Windows 64-bit) Server: v1.6-release-22780 (Windows 64-bit)
Additional context
My debug script results are shown here for better illustration:
Relevant log output
No response
Security Policy