Skip to content

Commit 782d465

Browse files
added comment about illegal characters. code findings
1 parent 38a6fb6 commit 782d465

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

app/inpututils.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ QString InputUtils::getRelativePath( const QString &path, const QString &prefixP
10631063
QString relativePath = prefixDir.relativeFilePath( cleanPath );
10641064

10651065
// check if the path starts with ".." or is absolute (on Windows/different drives), it's not a "child"
1066-
if ( relativePath.startsWith( QLatin1String( ".." ) ) || QDir::isAbsolutePath( relativePath ) )
1066+
if ( relativePath.startsWith( QLatin1StringView( ".." ) ) || QDir::isAbsolutePath( relativePath ) )
10671067
{
10681068
return {};
10691069
}
@@ -1967,6 +1967,7 @@ QString InputUtils::sanitizeNode( const QString &input )
19671967
cleanOutput = cleanOutput.trimmed();
19681968

19691969
// remove illegal characters before using QFileInfo
1970+
// illegal characters: ASCII control letters, "\", "/", "?", "#", "<", ">", ":", "|", " " "
19701971
const static QRegularExpression illegalChars( QStringLiteral( "[\x00-\x1f<>:|?*\"/\\\\]" ) );
19711972
cleanOutput.replace( illegalChars, QStringLiteral( "_" ) );
19721973

@@ -1985,15 +1986,15 @@ QString InputUtils::sanitizeNode( const QString &input )
19851986
);
19861987
if ( reservedNames.match( base.trimmed() ).hasMatch() )
19871988
{
1988-
base = base.trimmed() + QLatin1Char( '_' );
1989+
base = base.trimmed() + QStringLiteral( "_" );
19891990
}
19901991
}
19911992
#endif
19921993

19931994
// reassemble
19941995
if ( !suffix.isEmpty() )
19951996
{
1996-
return base + QLatin1Char( '.' ) + suffix;
1997+
return base + QStringLiteral( "." ) + suffix;
19971998
}
19981999
return base;
19992000
}
@@ -2010,8 +2011,8 @@ void InputUtils::sanitizePath( QString &path )
20102011
cleanPath.replace( QStringLiteral( "#" ), QStringLiteral( "_" ) );
20112012

20122013
// parse file prefix and path
2013-
QUrl url = QUrl::fromUserInput( cleanPath );
2014-
bool isUrl = path.startsWith( QLatin1String( "file:" ), Qt::CaseInsensitive );
2014+
const QUrl url = QUrl::fromUserInput( cleanPath );
2015+
const bool isUrl = path.startsWith( QStringLiteral( "file:" ), Qt::CaseInsensitive );
20152016

20162017
// if it has the file prefix, we will get rid of it
20172018
if ( isUrl )

0 commit comments

Comments
 (0)