Skip to content

Commit

Permalink
Prevent S&R to Internet w/o full URL (#322)
Browse files Browse the repository at this point in the history
- Fix check for empty project name
- Save Internet URL only if logged in
- Autogenerate Binding Redirects

Fixes https://jira.sil.org/browse/LT-21462
  • Loading branch information
papeh authored Jul 12, 2023
1 parent fdc43b0 commit 80bee2f
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Chorus/Chorus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<AssemblyTitle>Chorus</AssemblyTitle>
<PackageId>SIL.Chorus.App</PackageId>
<OutputType>Exe</OutputType>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Chorus/UI/Settings/SendReceiveSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private void okButton_Click(object sender, EventArgs e)
{
if(_internetButtonEnabledCheckBox.Checked)
{
_internetModel.SaveSettings();
_internetModel.SaveSettingsThatMakeSense();
}
_model.SaveSettings();
Properties.Settings.Default.InternetEnabled = _internetButtonEnabledCheckBox.Checked;
Expand Down
1 change: 1 addition & 0 deletions src/ChorusHub/ChorusHub.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<AssemblyTitle>ChorusHub</AssemblyTitle>
<PackageId>SIL.Chorus.ChorusHub</PackageId>
<OutputType>WinExe</OutputType>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/ChorusHubApp/ChorusHubApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<AssemblyTitle>ChorusHubApp</AssemblyTitle>
<PackageId>SIL.Chorus.ChorusHubApp</PackageId>
<OutputType>WinExe</OutputType>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/ChorusMerge/ChorusMerge.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<OutputType>Exe</OutputType>
<TargetFrameworks>net461;net6.0</TargetFrameworks>
<RepositoryUrl>https://github.com/sillsdev/chorus.git</RepositoryUrl>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>

<ItemGroup>
Expand Down
18 changes: 17 additions & 1 deletion src/LibChorus/Model/ServerSettingsModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public bool CanLogIn
{
return !string.IsNullOrEmpty(Username) &&
!string.IsNullOrEmpty(Password) &&
HasLoggedIn ? UsernameOrPasswordEdited : true;
(!HasLoggedIn || UsernameOrPasswordEdited);
}
}

Expand All @@ -237,6 +237,22 @@ public bool CanLogIn
/// </summary>
private bool UsernameOrPasswordEdited { get; set; }

/// <summary>
/// Save only the settings that the user has modified.
/// If the user has not logged in to select a project ID, don't save a bare URL to hgrc (LT-21462)
/// </summary>
public void SaveSettingsThatMakeSense()
{
if (HasLoggedIn || IsCustomUrl)
{
SaveSettings();
}
else
{
SaveUserSettings();
}
}

/// <summary>
/// Save the settings in the folder's .hg, creating the folder and settings if necessary.
/// This is only available if you previously called InitFromProjectPath(). It isn't used
Expand Down
2 changes: 1 addition & 1 deletion src/LibChorus/VcsDrivers/Mercurial/HgRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2180,7 +2180,7 @@ public bool GetIsReadyForInternetSendReceive(out string message)
return false;
}

if (string.IsNullOrEmpty(uri.PathAndQuery))
if (string.IsNullOrEmpty(uri.PathAndQuery?.Trim('/')))
{
message = string.Format(
LocalizationManager.GetString("GetInternetStatus.ProjectNameIsMissing", "The project name at {0} is missing."), uri.Host);
Expand Down
1 change: 1 addition & 0 deletions src/SampleApp/SampleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<Description>Sample app for chorus.</Description>
<OutputType>WinExe</OutputType>
<IsPackable>false</IsPackable>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 80bee2f

Please sign in to comment.