Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gruve-p committed Jan 30, 2025
2 parents 9fb1192 + 192d339 commit 7ac7d5d
Show file tree
Hide file tree
Showing 51 changed files with 308 additions and 410 deletions.
36 changes: 19 additions & 17 deletions BTCPayServer.Abstractions/Services/Safe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,35 @@ public IHtmlContent Json(object model)
return _htmlHelper.Raw(_jsonHelper.Serialize(model));
}

public IHtmlContent Meta(string inputHtml) => _htmlHelper.Raw(RawMeta(inputHtml, out _));

public string RawMeta(string inputHtml, out bool isHtmlModified)
{
bool bHtmlModified;
HtmlSanitizer _metaSanitizer = new HtmlSanitizer();
HtmlSanitizer sane = new HtmlSanitizer();

_metaSanitizer.AllowedTags.Clear();
_metaSanitizer.AllowedTags.Add("meta");
sane.AllowedTags.Clear();
sane.AllowedTags.Add("meta");

_metaSanitizer.AllowedAttributes.Clear();
_metaSanitizer.AllowedAttributes.Add("name");
_metaSanitizer.AllowedAttributes.Add("http-equiv");
_metaSanitizer.AllowedAttributes.Add("content");
_metaSanitizer.AllowedAttributes.Add("value");
_metaSanitizer.AllowedAttributes.Add("property");
sane.AllowedAttributes.Clear();
sane.AllowedAttributes.Add("name");
sane.AllowedAttributes.Add("http-equiv");
sane.AllowedAttributes.Add("content");
sane.AllowedAttributes.Add("value");
sane.AllowedAttributes.Add("property");

_metaSanitizer.AllowDataAttributes = false;
sane.AllowDataAttributes = false;

_metaSanitizer.RemovingTag += (sender, e) => bHtmlModified = true;
_metaSanitizer.RemovingAtRule += (sender, e) => bHtmlModified = true;
_metaSanitizer.RemovingAttribute += (sender, e) => bHtmlModified = true;
_metaSanitizer.RemovingComment += (sender, e) => bHtmlModified = true;
_metaSanitizer.RemovingCssClass += (sender, e) => bHtmlModified = true;
_metaSanitizer.RemovingStyle += (sender, e) => bHtmlModified = true;
sane.RemovingTag += (sender, e) => bHtmlModified = true;
sane.RemovingAtRule += (sender, e) => bHtmlModified = true;
sane.RemovingAttribute += (sender, e) => bHtmlModified = true;
sane.RemovingComment += (sender, e) => bHtmlModified = true;
sane.RemovingCssClass += (sender, e) => bHtmlModified = true;
sane.RemovingStyle += (sender, e) => bHtmlModified = true;

bHtmlModified = false;

var sRet = _metaSanitizer.Sanitize(inputHtml);
var sRet = sane.Sanitize(inputHtml);
isHtmlModified = bHtmlModified;

return sRet;
Expand Down
138 changes: 0 additions & 138 deletions BTCPayServer.Client/App/IBTCPayAppHubClient.cs

This file was deleted.

8 changes: 0 additions & 8 deletions BTCPayServer.Client/App/Models/AcceptInviteRequest.cs

This file was deleted.

10 changes: 0 additions & 10 deletions BTCPayServer.Client/App/Models/AcceptInviteResult.cs

This file was deleted.

10 changes: 0 additions & 10 deletions BTCPayServer.Client/App/Models/AccessTokenResult.cs

This file was deleted.

13 changes: 0 additions & 13 deletions BTCPayServer.Client/App/Models/AppInstanceInfo.cs

This file was deleted.

44 changes: 0 additions & 44 deletions BTCPayServer.Client/App/Models/AppUserInfo.cs

This file was deleted.

7 changes: 0 additions & 7 deletions BTCPayServer.Client/App/Models/AuthenticationResult.cs

This file was deleted.

11 changes: 0 additions & 11 deletions BTCPayServer.Client/App/Models/CreateStoreData.cs

This file was deleted.

10 changes: 0 additions & 10 deletions BTCPayServer.Client/App/Models/LoginRequest.cs

This file was deleted.

8 changes: 0 additions & 8 deletions BTCPayServer.Client/App/Models/ResetPasswordRequest.cs

This file was deleted.

2 changes: 0 additions & 2 deletions BTCPayServer.Rating/CurrencyPair.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public static bool TryParse(string str, out CurrencyPair value)
ArgumentNullException.ThrowIfNull(str);
value = null;
str = str.Trim();
if (str.Length > 12)
return false;
var splitted = str.Split(new[] { '_', '-' }, StringSplitOptions.RemoveEmptyEntries);
if (splitted.Length == 2)
{
Expand Down
12 changes: 9 additions & 3 deletions BTCPayServer.Tests/GreenfieldAPITests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using BTCPayServer.PayoutProcessors.Lightning;
using BTCPayServer.Plugins.PointOfSale.Controllers;
using BTCPayServer.Plugins.PointOfSale.Models;
using BTCPayServer.Rating;
using BTCPayServer.Services;
using BTCPayServer.Services.Apps;
using BTCPayServer.Services.Invoices;
Expand Down Expand Up @@ -3314,6 +3315,12 @@ await AssertHttpError(404, async () =>
await viewOnlyClient.SendHttpRequest($"api/v1/stores/{store.Id}/payment-methods/onchain/BTC/preview", new JObject() { ["config"] = xpub.ToString() }, HttpMethod.Post);

var method = await client.UpdateStorePaymentMethod(store.Id, "BTC-CHAIN", new UpdatePaymentMethodRequest() { Enabled = true, Config = JValue.CreateString(xpub.ToString())});
var method2 = await client.UpdateStorePaymentMethod(store.Id, "BTC-CHAIN", new UpdatePaymentMethodRequest() { Enabled = true, Config = new JObject() { ["derivationScheme"] = xpub.ToString(), ["label"] = "test", ["accountKeyPath"] = "aaaaaaaa/84'/0'/0'" } });
Assert.Equal("aaaaaaaa", method2.Config["accountKeySettings"][0]["rootFingerprint"].ToString());
Assert.Equal("84'/0'/0'", method2.Config["accountKeySettings"][0]["accountKeyPath"].ToString());
var method3 = await client.UpdateStorePaymentMethod(store.Id, "BTC-CHAIN", new UpdatePaymentMethodRequest() { Enabled = true, Config = new JObject() { ["derivationScheme"] = xpub.ToString() } });

Assert.Equal(method.ToJson(), method3.ToJson());

Assert.Equal(firstAddress, (await viewOnlyClient.PreviewStoreOnChainPaymentMethodAddresses(store.Id, "BTC")).Addresses.First().Address);
await AssertHttpError(403, async () =>
Expand Down Expand Up @@ -3378,7 +3385,6 @@ await client.GenerateOnChainWallet(store.Id, "BTC",

Assert.Equal(24, generateResponse.Mnemonic.Words.Length);
Assert.Equal(Wordlist.Japanese, generateResponse.Mnemonic.WordList);

}

[Fact(Timeout = 60 * 2 * 1000)]
Expand Down Expand Up @@ -4819,9 +4825,9 @@ await AssertValidationError(new[] { "PreferredSource", "Spread" }, () =>
clientBasic.UpdateStoreRateConfiguration(user.StoreId, new StoreRateConfiguration() { IsCustomScript = false, PreferredSource = "coingeckoOOO", Spread = -1m }));

await AssertValidationError(new[] { "currencyPair" }, () =>
clientBasic.PreviewUpdateStoreRateConfiguration(user.StoreId, new StoreRateConfiguration() { IsCustomScript = false, PreferredSource = "coingecko" }, new[] { "BTC_USD_USD_BTC" }));
clientBasic.PreviewUpdateStoreRateConfiguration(user.StoreId, new StoreRateConfiguration() { IsCustomScript = false, PreferredSource = "coingecko" }, new[] { "BTCUSDUSDBTC" }));
await AssertValidationError(new[] { "PreferredSource", "currencyPair" }, () =>
clientBasic.PreviewUpdateStoreRateConfiguration(user.StoreId, new StoreRateConfiguration() { IsCustomScript = false, PreferredSource = "coingeckoOOO" }, new[] { "BTC_USD_USD_BTC" }));
clientBasic.PreviewUpdateStoreRateConfiguration(user.StoreId, new StoreRateConfiguration() { IsCustomScript = false, PreferredSource = "coingeckoOOO" }, new[] { "BTCUSDUSDBTC" }));
}
}
}
4 changes: 2 additions & 2 deletions BTCPayServer.Tests/PayJoinTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,12 @@ public async Task CanUsePayjoin2()
var request = await fakeServer.GetNextRequest();
Assert.Equal("1", request.Request.Query["v"][0]);
Assert.Equal(changeIndex.ToString(), request.Request.Query["additionalfeeoutputindex"][0]);
Assert.Equal("1146", request.Request.Query["maxadditionalfeecontribution"][0]);
Assert.Equal("1853", request.Request.Query["maxadditionalfeecontribution"][0]);

TestLogs.LogInformation("The payjoin receiver tries to make us pay lots of fee");
var originalPSBT = await ParsePSBT(request);
var proposalTx = originalPSBT.GetGlobalTransaction();
proposalTx.Outputs[changeIndex].Value -= Money.Satoshis(1147);
proposalTx.Outputs[changeIndex].Value -= Money.Satoshis(1854);
await request.Response.WriteAsync(PSBT.FromTransaction(proposalTx, Network.RegTest).ToBase64(), Encoding.UTF8);
fakeServer.Done();
var ex = await Assert.ThrowsAsync<PayjoinSenderException>(async () => await requesting);
Expand Down
Loading

0 comments on commit 7ac7d5d

Please sign in to comment.