diff --git a/Pages/Index.cshtml b/Pages/Index.cshtml index 8ab24df..e73c9dd 100644 --- a/Pages/Index.cshtml +++ b/Pages/Index.cshtml @@ -74,19 +74,19 @@ else { } function copy_hash_np() { - copyToClipboard('[#np](@Log.NowPlayingUrl) @Model.CopyArtist - @Model.CopyAlbum'); + copyToClipboard('[#np](@Html.Raw(Log.NowPlayingUrl)) @Html.Raw(Model.CopyArtist) - @Html.Raw(Model.CopyAlbum)'); reset_copy_labels(); document.getElementById('copy_hash_np').innerText = 'Copy #np (Copied!)'; } function copy_journal_full() { - copyToClipboard('[@Model.CopyArtist](' + getUrl('@Model.LogArtist') + ') - [@Model.CopyAlbum](' + getUrl('@Model.LogArtist', '@Model.LogAlbum') + ')') + copyToClipboard('[@Html.Raw(Model.CopyArtist)](' + getUrl('@Html.Raw(Model.LogArtist)') + ') - [@Html.Raw(Model.CopyAlbum)](' + getUrl('@Html.Raw(Model.LogArtist)', '@Html.Raw(Model.LogAlbum)') + ')') reset_copy_labels(); document.getElementById('copy_journal_full').innerText = 'Copy journal (full) (Copied!)'; } function copy_journal_album() { - copyToClipboard(', [@Model.CopyAlbum](' + getUrl('@Model.LogArtist', '@Model.LogAlbum') + ')') + copyToClipboard(', [@Html.Raw(Model.CopyAlbum)](' + getUrl('@Html.Raw(Model.LogArtist)', '@Html.Raw(Model.LogAlbum)') + ')') reset_copy_labels(); document.getElementById('copy_journal_album').innerText = 'Copy journal (album only) (Copied!)'; } diff --git a/Pages/Index.cshtml.cs b/Pages/Index.cshtml.cs index f1716b7..2ebdc19 100644 --- a/Pages/Index.cshtml.cs +++ b/Pages/Index.cshtml.cs @@ -52,11 +52,11 @@ namespace webmusic.Pages { if (Log.StatisticsEnabled && Request.Headers["Remote-User"].Equals(Log.StatisticsUser) && Files.Any()) { var pathparts = Displaypath.Split(System.IO.Path.DirectorySeparatorChar); if (pathparts.Length > 2) { - CopyAlbum = pathparts[Index.FromEnd(1)]; - CopyArtist = pathparts[Index.FromEnd(2)]; - LogAlbum = HttpUtility.UrlPathEncode(pathparts[Index.FromEnd(1)]); - LogArtist = HttpUtility.UrlPathEncode(pathparts[Index.FromEnd(2)]); - LogUrl = Request.GetEncodedUrl(); + CopyAlbum = pathparts[Index.FromEnd(1)].Replace("'", "\\'"); + CopyArtist = pathparts[Index.FromEnd(2)].Replace("'", "\\'");; + LogAlbum = HttpUtility.UrlPathEncode(pathparts[Index.FromEnd(1)]).Replace("'", "\\'");; + LogArtist = HttpUtility.UrlPathEncode(pathparts[Index.FromEnd(2)]).Replace("'", "\\'");; + LogUrl = Request.GetEncodedUrl().Replace("'", "\\'");; LogConditionsMet = true; } }