Skip to content

Commit

Permalink
merge hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm360 committed May 21, 2023
2 parents 124f7f8 + 928f91b commit 51f2990
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 18 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/stable-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Stable release to MyGet
name: Stable release deploy to MyGet

on:
push:
Expand All @@ -10,14 +10,16 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
dotnet-version: |
6.0.x
7.0.x
- name: Build with dotnet
run: dotnet build --configuration Release
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/unstable-release.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
name: Unstable release to MyGet
name: Unstable release deploy to MyGet

on:
push:
branches:
- dev
- 'release/**'

jobs:
build-test-package:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
dotnet-version: |
6.0.x
7.0.x
- name: Build with dotnet
run: dotnet build --configuration Release
Expand Down
32 changes: 32 additions & 0 deletions src/EthernaACR/Attributes/SwarmResourceValidationAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2021-present Etherna Sagl
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System.ComponentModel.DataAnnotations;
using System.Text.RegularExpressions;

namespace Etherna.ACR.Attributes
{
public sealed class SwarmResourceValidationAttribute : ValidationAttribute
{
private static readonly Regex SwarmResourceRegex = new("^[A-Fa-f0-9]{64}$");

protected override ValidationResult? IsValid(object? value, ValidationContext validationContext)
{
if (value is string stringValue && SwarmResourceRegex.IsMatch(stringValue))
return ValidationResult.Success;

return new ValidationResult("Argument is not a valid swarm resource");
}
}
}
7 changes: 4 additions & 3 deletions src/EthernaACR/EthernaACR.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<RootNamespace>Etherna.ACR</RootNamespace>

Expand All @@ -28,11 +28,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="GitVersion.MsBuild" Version="5.11.1">
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.11" />
<PackageReference Include="HtmlSanitizer" Version="8.0.645" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.16" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
6 changes: 4 additions & 2 deletions src/EthernaACR/Helpers/EmailHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ namespace Etherna.ACR.Helpers
public static class EmailHelper
{
// Consts.
public const string EmailRegex = @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z";
public static readonly Regex EmailRegex = new(
@"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z",
RegexOptions.IgnoreCase);

// Static methods.
public static bool IsValidEmail(string email) =>
Regex.IsMatch(email, EmailRegex, RegexOptions.IgnoreCase);
EmailRegex.IsMatch(email);

public static string NormalizeEmail(string email)
{
Expand Down
11 changes: 9 additions & 2 deletions src/EthernaACR/Pages/Shared/_StatusMessage.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,20 @@
* limitations under the License.
*@

@using Ganss.Xss;

@model string
@{
var htmlSanitizer = new HtmlSanitizer();
var htmlMessage = htmlSanitizer.Sanitize(
(Model ?? "").Replace("\n", "<br>"));
}

@if (!String.IsNullOrEmpty(Model))
{
var statusMessageClass = Model.StartsWith("Error") ? "danger" : "success";
var statusMessageClass = htmlMessage.StartsWith("Error") ? "danger" : "success";
<div class="alert alert-@statusMessageClass alert-dismissible fade show" role="alert">
@Model
@Html.Raw(htmlMessage)
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
}

0 comments on commit 51f2990

Please sign in to comment.