Skip to content

Commit

Permalink
fix(frontend): escaping properly and making url safe
Browse files Browse the repository at this point in the history
  • Loading branch information
Thundernerd committed Jan 2, 2024
1 parent fdee121 commit f2f1f54
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/Mangarr.Frontend/Pages/Manga/Link/AddModal.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@using System.Web
<div class="modal fade" id="[email protected](MangaId)" tabindex="-1">
<div class="modal fade" id="add-manga-modal-@SafeMangaId" tabindex="-1">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
Expand Down
11 changes: 7 additions & 4 deletions src/Mangarr.Frontend/Pages/Manga/Link/AddModal.razor.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
using Microsoft.AspNetCore.Components;
using System.Web;
using Microsoft.AspNetCore.Components;

namespace Mangarr.Frontend.Pages.Manga.Link;

public partial class AddModal
{
private bool _monitorNewChaptersOnly;
[Parameter] public string Id { get; set; } = null!;
[Parameter] public string Identifier { get; set; } = null!;
[Parameter] public string MangaId { get; set; } = null!;

[Inject] public NavigationManager NavigationManager { get; set; } = null!;
private string SafeMangaId => MangaId.Replace('+', '-').Replace('/', '_').Replace('=', '.');

private bool _monitorNewChaptersOnly;
[Inject] public NavigationManager NavigationManager { get; set; } = null!;

private void ToggleMonitorNewChaptersOnly() => _monitorNewChaptersOnly = !_monitorNewChaptersOnly;

private void OnAddClick() =>
NavigationManager.NavigateTo($"/manga/{Id}/add/{Identifier}/{MangaId}/{_monitorNewChaptersOnly}");
NavigationManager.NavigateTo(
$"/manga/{Id}/add/{Identifier}/{HttpUtility.UrlEncode(MangaId)}/{_monitorNewChaptersOnly}");
}
5 changes: 2 additions & 3 deletions src/Mangarr.Frontend/Pages/Manga/Link/ContentSourceItem.razor
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
@using System.Web
<div class="d-flex flex-column card p-2 me-2 content-source-item">
<div class="d-flex flex-column card p-2 me-2 content-source-item">
<img class="content-source-item-cover" src="@CoverImage" alt="cover" referrerpolicy="no-referrer">
<p class="text-truncate">@Title</p>
<button class="btn btn-primary" type="button" data-bs-toggle="modal" data-bs-target="#add-manga-modal-@HttpUtility.UrlEncode(MangaId)">Select</button>
<button class="btn btn-primary" type="button" data-bs-toggle="modal" data-bs-target="#add-manga-modal-@SafeMangaId">Select</button>
</div>

<AddModal Id="@Id" Identifier="@Identifier" MangaId="@MangaId"/>
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ public partial class ContentSourceItem
private string CoverImage => Item.CoverUrl;

private string MangaId => Item.Id;
private string SafeMangaId => MangaId.Replace('+', '-').Replace('/', '_').Replace('=', '.');
}

0 comments on commit f2f1f54

Please sign in to comment.