Skip to content

Commit

Permalink
Another tweak/protection against laoding file/uri after "Clear Sessio…
Browse files Browse the repository at this point in the history
…n..." action.
  • Loading branch information
wcjohns committed Apr 22, 2023
1 parent dc1bbc9 commit 2a277df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions InterSpec/InterSpecServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ namespace InterSpecServer
The file path must either be a file-system path to a spectrum file, or it can be a App URL with
the schema "interspec://..."
Call #clear_file_to_open_on_load after you have succesfully handled the file, or else the "Clear Session..."
action will cause the session to load this same file again.
Call #clear_file_to_open_on_load after you have succesfully handled the file to remove this request
and not accidentally request to load it later.
Throws exception if an invalid session token, or the session has already been loaded.
*/
Expand All @@ -232,7 +232,7 @@ namespace InterSpecServer
std::string file_to_open_on_load( const std::string &session_token );

/** Once you have loaded the file/url from #file_to_open_on_load, call this function to avoid
loading the spectrum again if "Clear Session..." action is taken by the user.
loading the file/url again later
*/
void clear_file_to_open_on_load( const std::string &session_token );

Expand Down
5 changes: 3 additions & 2 deletions src/InterSpecApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,12 +534,13 @@ void InterSpecApp::setupWidgets( const bool attemptStateLoad )
const Http::ParameterMap &parmap = environment().getParameterMap();

#if( !BUILD_FOR_WEB_DEPLOYMENT )
if( !m_externalToken.empty() )
// The check of `attemptStateLoad` isnt strickly needed, as #file_to_open_on_load contents
// will be cleared
if( attemptStateLoad && !m_externalToken.empty() )
{
const string initial_file = InterSpecServer::file_to_open_on_load( m_externalToken );
if( !initial_file.empty() )
{

if( SpecUtils::istarts_with(initial_file, "interspec://")
|| SpecUtils::istarts_with(initial_file, "RADDATA://G0/") )
{
Expand Down

0 comments on commit 2a277df

Please sign in to comment.