Skip to content

Commit 49a4da8

Browse files
committed
Merge from master
2 parents 9f77082 + 9ed6c79 commit 49a4da8

File tree

22 files changed

+810
-133
lines changed

22 files changed

+810
-133
lines changed

.github/workflows/wf-build-release-ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
workflow_dispatch:
77
jobs:
88
build:
9-
runs-on: windows-2019
9+
runs-on: windows-latest
1010
env:
1111
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
1212
steps:
@@ -33,17 +33,17 @@ jobs:
3333
uses: actions/upload-artifact@v4
3434
with:
3535
name: Compiled project
36-
path: C:\a\qrcoder\qrcoder
36+
path: ${{ github.workspace }}
3737

3838
test:
3939
needs: build
40-
runs-on: windows-2019
40+
runs-on: windows-latest
4141
steps:
4242
- name: Download artifacts
4343
uses: actions/download-artifact@v4
4444
with:
4545
name: Compiled project
46-
path: C:\a\qrcoder\qrcoder
46+
path: ${{ github.workspace }}
4747

4848
- name: Install additional .NET SDKs
4949
uses: actions/setup-dotnet@v4
@@ -139,15 +139,15 @@ jobs:
139139

140140
pack-push-ci:
141141
needs: test
142-
runs-on: windows-2019
142+
runs-on: windows-latest
143143
env:
144144
GH_PKG_SEC: ${{ secrets.GITHUB_TOKEN }}
145145
steps:
146146
- name: Download artifacts
147147
uses: actions/download-artifact@v4
148148
with:
149149
name: Compiled project
150-
path: C:\a\qrcoder\qrcoder
150+
path: ${{ github.workspace }}
151151

152152
- name: Install additional .NET SDKs
153153
uses: actions/setup-dotnet@v4
@@ -193,7 +193,7 @@ jobs:
193193
clean:
194194
needs: [build, test, pack-push-ci]
195195
if: always()
196-
runs-on: windows-2019
196+
runs-on: windows-latest
197197
steps:
198198
- name: Delete artifacts
199199
uses: GeekyEggo/delete-artifact@v5

.github/workflows/wf-build-release.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
required: true
88
jobs:
99
build:
10-
runs-on: windows-2019
10+
runs-on: windows-latest
1111
env:
1212
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
1313
steps:
@@ -34,17 +34,17 @@ jobs:
3434
uses: actions/upload-artifact@v4
3535
with:
3636
name: Compiled project
37-
path: C:\a\qrcoder\qrcoder
37+
path: ${{ github.workspace }}
3838

3939
test:
4040
needs: build
41-
runs-on: windows-2019
41+
runs-on: windows-latest
4242
steps:
4343
- name: Download artifacts
4444
uses: actions/download-artifact@v4
4545
with:
4646
name: Compiled project
47-
path: C:\a\qrcoder\qrcoder
47+
path: ${{ github.workspace }}
4848

4949
- name: Install additional .NET SDKs
5050
uses: actions/setup-dotnet@v4
@@ -139,15 +139,15 @@ jobs:
139139

140140
pack-push-release:
141141
needs: test
142-
runs-on: windows-2019
142+
runs-on: windows-latest
143143
env:
144144
GH_PKG_SEC: ${{ secrets.GITHUB_TOKEN }}
145145
steps:
146146
- name: Download artifacts
147147
uses: actions/download-artifact@v4
148148
with:
149149
name: Compiled project
150-
path: C:\a\qrcoder\qrcoder
150+
path: ${{ github.workspace }}
151151

152152
- name: Install additional .NET SDKs
153153
uses: actions/setup-dotnet@v4
@@ -187,7 +187,7 @@ jobs:
187187
clean:
188188
needs: [build, test, pack-push-release]
189189
if: always()
190-
runs-on: windows-2019
190+
runs-on: windows-latest
191191
steps:
192192
- name: Delete artifacts
193193
uses: GeekyEggo/delete-artifact@v5

.github/workflows/wf-build-test.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ on:
66
workflow_dispatch:
77
jobs:
88
build:
9-
runs-on: windows-2019
9+
runs-on: windows-latest
10+
env:
11+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
1012
steps:
1113
- uses: actions/checkout@v4
1214
name: Checkout Code
@@ -26,11 +28,11 @@ jobs:
2628
uses: actions/upload-artifact@v4
2729
with:
2830
name: Compiled project
29-
path: C:\a\qrcoder\qrcoder
31+
path: ${{ github.workspace }}
3032

3133
test:
3234
needs: build
33-
runs-on: windows-2019
35+
runs-on: windows-latest
3436
strategy:
3537
matrix:
3638
dotnet-framework:
@@ -48,7 +50,7 @@ jobs:
4850
uses: actions/download-artifact@v4
4951
with:
5052
name: Compiled project
51-
path: C:\a\qrcoder\qrcoder
53+
path: ${{ github.workspace }}
5254

5355
- name: Install .NET SDK ${{ matrix.dotnet-framework.sdk }}
5456
uses: actions/setup-dotnet@v4
@@ -70,7 +72,7 @@ jobs:
7072
uses: actions/download-artifact@v4
7173
with:
7274
name: Compiled project
73-
path: C:\a\qrcoder\qrcoder
75+
path: ${{ github.workspace }}
7476

7577
- name: Install additional .NET SDKs
7678
uses: actions/setup-dotnet@v4
@@ -88,7 +90,7 @@ jobs:
8890
clean:
8991
needs: [build, test, additional-tests]
9092
if: always()
91-
runs-on: windows-2019
93+
runs-on: windows-latest
9294
steps:
9395
- name: Delete artifacts
9496
uses: GeekyEggo/delete-artifact@v5

QRCoder/PayloadGenerator/BezahlCode.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public static partial class PayloadGenerator
1111
public class BezahlCode : Payload
1212
{
1313
//BezahlCode specification: http://www.bezahlcode.de/wp-content/uploads/BezahlCode_TechDok.pdf
14+
//SEPA Credit Transfer Guideline: https://www.europeanpaymentscouncil.eu/sites/default/files/kb/file/2024-03/EPC069-12%20v3.1%20Quick%20Response%20Code%20-%20Guidelines%20to%20Enable%20the%20Data%20Capture%20for%20the%20Initiation%20of%20an%20SCT.pdf
1415

1516
private readonly string? _iban, _bic, _account, _bnc, _sepaReference, _creditorId, _mandateId, _periodicTimeunit;
1617
private readonly string _name, _reason;
@@ -143,22 +144,26 @@ public BezahlCode(AuthorityType authority, string name, string account, string b
143144

144145
_authority = authority;
145146

147+
var oldWayFilled = (!string.IsNullOrEmpty(account) && !string.IsNullOrEmpty(bnc));
148+
var newWayFilled = (!string.IsNullOrEmpty(iban) && !string.IsNullOrEmpty(bic));
149+
146150
if (name.Length > 70)
147151
throw new BezahlCodeException("(Payee-)Name must be shorter than 71 chars.");
148152
_name = name;
149153

150-
if (reason.Length > 27)
151-
throw new BezahlCodeException("Reasons texts have to be shorter than 28 chars.");
154+
//Limit reason length depending on payment type
155+
//140 chars for SEPA payments and 27 chars for others
156+
var reasonLength = authority == AuthorityType.periodicsinglepaymentsepa || authority == AuthorityType.singledirectdebitsepa || authority == AuthorityType.singlepaymentsepa || (authority == AuthorityType.contact_v2 && newWayFilled) ? 140 : 27;
157+
if (reason.Length > reasonLength)
158+
throw new BezahlCodeException($"Reasons texts have to be shorter than {reasonLength + 1} chars.");
152159
_reason = reason;
153160

154-
var oldWayFilled = (!string.IsNullOrEmpty(account) && !string.IsNullOrEmpty(bnc));
155-
var newWayFilled = (!string.IsNullOrEmpty(iban) && !string.IsNullOrEmpty(bic));
156-
157161
//Non-SEPA payment types
158162
#pragma warning disable CS0612
159163
if (authority == AuthorityType.periodicsinglepayment || authority == AuthorityType.singledirectdebit || authority == AuthorityType.singlepayment || authority == AuthorityType.contact || (authority == AuthorityType.contact_v2 && oldWayFilled))
160164
{
161165
#pragma warning restore CS0612
166+
162167
if (!Regex.IsMatch(account.Replace(" ", ""), @"^[0-9]{1,9}$"))
163168
throw new BezahlCodeException("The account entered isn't valid.");
164169
_account = account.Replace(" ", "").ToUpper();

QRCoder/QRCodeData.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ public QRCodeData(byte[] rawData, Compression compressMode)
9595
var modules = new Queue<bool>(8 * bytes.Count);
9696
foreach (var b in bytes)
9797
{
98-
var bArr = new BitArray(new byte[] { b });
9998
for (int i = 7; i >= 0; i--)
10099
{
101100
modules.Enqueue((b & (1 << i)) != 0);
@@ -194,10 +193,12 @@ public void SaveRawData(string filePath, Compression compressMode)
194193
/// <summary>
195194
/// Gets the number of modules per side from the specified version.
196195
/// </summary>
197-
/// <param name="version">The version of the QR code.</param>
196+
/// <param name="version">The version of the QR code (1 to 40, or -1 to -4 for Micro QR codes).</param>
198197
/// <returns>Returns the number of modules per side.</returns>
199198
private static int ModulesPerSideFromVersion(int version)
200-
=> 21 + (version - 1) * 4;
199+
=> version > 0
200+
? 21 + (version - 1) * 4
201+
: 11 + (-version - 1) * 2;
201202

202203
/// <summary>
203204
/// Releases all resources used by the <see cref="QRCodeData"/>.

0 commit comments

Comments
 (0)