diff options
| author | Mark Palange <palange@lindenlab.com> | 2008-11-07 17:51:03 +0000 | 
|---|---|---|
| committer | Mark Palange <palange@lindenlab.com> | 2008-11-07 17:51:03 +0000 | 
| commit | f89f19990cbb9f3f2e7473ac6c159098bdfabec7 (patch) | |
| tree | e7fa406e2db5e9adc2e24e00557d7b3d3f93203a /indra/llvfs | |
| parent | b2bfb128e7d30e1cdb293a2ac192a0cbe63fe528 (diff) | |
QAR-992 Merging revisions 101012-101170,101686-101687 of svn+ssh://svn.lindenlab.com/svn/linden/qa/viewer_combo_1-22-merge into linden/release
Diffstat (limited to 'indra/llvfs')
| -rw-r--r-- | indra/llvfs/lldir.cpp | 23 | ||||
| -rw-r--r-- | indra/llvfs/lldir.h | 14 | 
2 files changed, 32 insertions, 5 deletions
| diff --git a/indra/llvfs/lldir.cpp b/indra/llvfs/lldir.cpp index ff7bfde521..8acf7d88ca 100644 --- a/indra/llvfs/lldir.cpp +++ b/indra/llvfs/lldir.cpp @@ -497,6 +497,29 @@ std::string LLDir::getTempFilename() const  	return temp_filename;  } +// static +std::string LLDir::getScrubbedFileName(const std::string uncleanFileName) +{ +	std::string name(uncleanFileName); +	const std::string illegalChars(getForbiddenFileChars()); +	// replace any illegal file chars with and underscore '_' +	for( unsigned int i = 0; i < illegalChars.length(); i++ ) +	{ +		int j = -1; +		while((j = name.find(illegalChars[i])) > -1) +		{ +			name[j] = '_'; +		} +	} +	return name; +} + +// static +std::string LLDir::getForbiddenFileChars() +{ +	return "\\/:*?\"<>|"; +} +  void LLDir::setLindenUserDir(const std::string &first, const std::string &last)  {  	// if both first and last aren't set, assume we're grabbing the cached dir diff --git a/indra/llvfs/lldir.h b/indra/llvfs/lldir.h index b0255b4d00..a884ea7c76 100644 --- a/indra/llvfs/lldir.h +++ b/indra/llvfs/lldir.h @@ -64,12 +64,12 @@ class LLDir  	virtual void initAppDirs(const std::string &app_name) = 0;   public:	 -	 virtual S32 deleteFilesInDir(const std::string &dirname, const std::string &mask); +	virtual S32 deleteFilesInDir(const std::string &dirname, const std::string &mask);  // pure virtual functions -	 virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask) = 0; -	 virtual BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap) = 0; -	 virtual void getRandomFileInDir(const std::string &dirname, const std::string &mask, std::string &fname) = 0; +	virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask) = 0; +	virtual BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap) = 0; +	virtual void getRandomFileInDir(const std::string &dirname, const std::string &mask, std::string &fname) = 0;  	virtual std::string getCurPath() = 0;  	virtual BOOL fileExists(const std::string &filename) const = 0; @@ -104,7 +104,7 @@ class LLDir  	std::string getBaseFileName(const std::string& filepath, bool strip_exten = false) const;  	std::string getDirName(const std::string& filepath) const;  	std::string getExtension(const std::string& filepath) const; // Excludes '.', e.g getExtension("foo.wav") == "wav" -	 +  	// these methods search the various skin paths for the specified file in the following order:  	// getUserSkinDir(), getSkinDir(), getDefaultSkinDir()  	std::string findSkinnedFilename(const std::string &filename) const; @@ -114,6 +114,10 @@ class LLDir  	// random filename in common temporary directory  	std::string getTempFilename() const; +	// For producing safe download file names from potentially unsafe ones +	static std::string getScrubbedFileName(const std::string uncleanFileName); +	static std::string getForbiddenFileChars(); +  	virtual void setChatLogsDir(const std::string &path);		// Set the chat logs dir to this user's dir  	virtual void setPerAccountChatLogsDir(const std::string &first, const std::string &last);		// Set the per user chat log directory.  	virtual void setLindenUserDir(const std::string &first, const std::string &last);		// Set the linden user dir to this user's dir | 
