Skip to content

Commit 815b3e7

Browse files
authored
Merge branch 'master' into patch-1
2 parents a53745c + a24c984 commit 815b3e7

15 files changed

+249
-112
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ jobs:
1010
env:
1111
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
1212
steps:
13-
- uses: actions/checkout@v1
13+
- uses: actions/checkout@v4
1414
name: Checkout Code
1515

1616
- name: Install additional .NET SDKs
17-
uses: actions/setup-dotnet@v1
17+
uses: actions/setup-dotnet@v4
1818
with:
1919
dotnet-version: |
2020
1.0.x
@@ -26,7 +26,7 @@ jobs:
2626
uses: microsoft/setup-msbuild@v1
2727

2828
- name: Setup NuGet
29-
uses: NuGet/setup-nuget@v1.0.2
29+
uses: NuGet/setup-nuget@v2
3030

3131
- name: Restore NuGet Packages
3232
run: nuget restore QRCoder.sln
@@ -35,7 +35,7 @@ jobs:
3535
run: msbuild QRCoder.sln /p:Configuration=Release /p:NoWarn="1182" /p:NoWarn="1701" /nr:false /t:Rebuild
3636

3737
- name: Upload artifacts
38-
uses: actions/upload-artifact@v1.0.0
38+
uses: actions/upload-artifact@v4
3939
with:
4040
name: Compiled project
4141
path: D:\a\qrcoder\qrcoder
@@ -45,13 +45,13 @@ jobs:
4545
runs-on: windows-2019
4646
steps:
4747
- name: Download artifacts
48-
uses: actions/download-artifact@v1.0.0
48+
uses: actions/download-artifact@v4
4949
with:
5050
name: Compiled project
5151
path: D:\a\qrcoder\qrcoder
5252

5353
- name: Install additional .NET SDKs
54-
uses: actions/setup-dotnet@v1
54+
uses: actions/setup-dotnet@v4
5555
with:
5656
dotnet-version: |
5757
1.0.x
@@ -123,16 +123,16 @@ jobs:
123123
needs: test
124124
runs-on: windows-2019
125125
env:
126-
GH_PKG_SEC: ${{ secrets.GH_PKG_REPO }}
126+
GH_PKG_SEC: ${{ secrets.GITHUB_TOKEN }}
127127
steps:
128128
- name: Download artifacts
129-
uses: actions/download-artifact@v1.0.0
129+
uses: actions/download-artifact@v4
130130
with:
131131
name: Compiled project
132132
path: D:\a\qrcoder\qrcoder
133133

134134
- name: Install additional .NET SDKs
135-
uses: actions/setup-dotnet@v1
135+
uses: actions/setup-dotnet@v4
136136
with:
137137
dotnet-version: |
138138
1.0.x
@@ -177,6 +177,6 @@ jobs:
177177
runs-on: windows-2019
178178
steps:
179179
- name: Delete artifacts
180-
uses: GeekyEggo/delete-artifact@v1.0.0
180+
uses: GeekyEggo/delete-artifact@v5
181181
with:
182182
name: Compiled project

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ jobs:
1111
env:
1212
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
1313
steps:
14-
- uses: actions/checkout@v1
14+
- uses: actions/checkout@v4
1515
name: Checkout Code
1616

1717
- name: Install additional .NET SDKs
18-
uses: actions/setup-dotnet@v1
18+
uses: actions/setup-dotnet@v4
1919
with:
2020
dotnet-version: |
2121
1.0.x
@@ -27,7 +27,7 @@ jobs:
2727
uses: microsoft/setup-msbuild@v1
2828

2929
- name: Setup NuGet
30-
uses: NuGet/setup-nuget@v1.0.2
30+
uses: NuGet/setup-nuget@v2
3131

3232
- name: Restore NuGet Packages
3333
run: nuget restore QRCoder.sln
@@ -36,7 +36,7 @@ jobs:
3636
run: msbuild QRCoder.sln /p:Configuration=Release /p:NoWarn="1182" /p:NoWarn="1701" /nr:false /t:Rebuild
3737

3838
- name: Upload artifacts
39-
uses: actions/upload-artifact@v1.0.0
39+
uses: actions/upload-artifact@v4
4040
with:
4141
name: Compiled project
4242
path: D:\a\qrcoder\qrcoder
@@ -46,7 +46,7 @@ jobs:
4646
runs-on: windows-2019
4747
steps:
4848
- name: Download artifacts
49-
uses: actions/download-artifact@v1.0.0
49+
uses: actions/download-artifact@v4
5050
with:
5151
name: Compiled project
5252
path: D:\a\qrcoder\qrcoder
@@ -123,16 +123,16 @@ jobs:
123123
needs: test
124124
runs-on: windows-2019
125125
env:
126-
GH_PKG_SEC: ${{ secrets.GH_PKG_REPO }}
126+
GH_PKG_SEC: ${{ secrets.GITHUB_TOKEN }}
127127
steps:
128128
- name: Download artifacts
129-
uses: actions/download-artifact@v1.0.0
129+
uses: actions/download-artifact@v4
130130
with:
131131
name: Compiled project
132132
path: D:\a\qrcoder\qrcoder
133133

134134
- name: Install additional .NET SDKs
135-
uses: actions/setup-dotnet@v1
135+
uses: actions/setup-dotnet@v4
136136
with:
137137
dotnet-version: |
138138
1.0.x
@@ -171,6 +171,6 @@ jobs:
171171
runs-on: windows-2019
172172
steps:
173173
- name: Delete artifacts
174-
uses: GeekyEggo/delete-artifact@v1.0.0
174+
uses: GeekyEggo/delete-artifact@v5
175175
with:
176176
name: Compiled project

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ jobs:
1010
env:
1111
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
1212
steps:
13-
- uses: actions/checkout@v1
13+
- uses: actions/checkout@v4
1414
name: Checkout Code
1515

1616
- name: Install additional .NET SDKs
17-
uses: actions/setup-dotnet@v1
17+
uses: actions/setup-dotnet@v4
1818
with:
1919
dotnet-version: |
2020
1.0.x
@@ -26,7 +26,7 @@ jobs:
2626
uses: microsoft/setup-msbuild@v1
2727

2828
- name: Setup NuGet
29-
uses: NuGet/setup-nuget@v1.0.2
29+
uses: NuGet/setup-nuget@v2
3030

3131
- name: Restore NuGet Packages
3232
run: nuget restore QRCoder.sln
@@ -35,7 +35,7 @@ jobs:
3535
run: msbuild QRCoder.sln /p:Configuration=Release /p:NoWarn="1182" /p:NoWarn="1701" /nr:false /t:Rebuild
3636

3737
- name: Upload artifacts
38-
uses: actions/upload-artifact@v1.0.0
38+
uses: actions/upload-artifact@v4
3939
with:
4040
name: Compiled project
4141
path: D:\a\qrcoder\qrcoder
@@ -45,13 +45,13 @@ jobs:
4545
runs-on: windows-2019
4646
steps:
4747
- name: Download artifacts
48-
uses: actions/download-artifact@v1.0.0
48+
uses: actions/download-artifact@v4
4949
with:
5050
name: Compiled project
5151
path: D:\a\qrcoder\qrcoder
5252

5353
- name: Install additional .NET SDKs
54-
uses: actions/setup-dotnet@v1
54+
uses: actions/setup-dotnet@v4
5555
with:
5656
dotnet-version: |
5757
1.0.x
@@ -89,6 +89,6 @@ jobs:
8989
runs-on: windows-2019
9090
steps:
9191
- name: Delete artifacts
92-
uses: GeekyEggo/delete-artifact@v1.0.0
92+
uses: GeekyEggo/delete-artifact@v5
9393
with:
9494
name: Compiled project

QRCoder/ASCIIQRCode.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public string[] GetLineByLineGraphic(int repeatPerModule, string darkColorString
5252
var lineBuilder = new StringBuilder();
5353
for (var x = 0; x < QrCodeData.ModuleMatrix.Count - quietZonesModifier; x++)
5454
{
55-
var module = QrCodeData.ModuleMatrix[x + quietZonesOffset][((y + verticalNumberOfRepeats) / verticalNumberOfRepeats - 1)+quietZonesOffset];
55+
var module = QrCodeData.ModuleMatrix[((y + verticalNumberOfRepeats) / verticalNumberOfRepeats - 1)+quietZonesOffset][x + quietZonesOffset];
5656
for (var i = 0; i < repeatPerModule; i++)
5757
{
5858
lineBuilder.Append(module ? darkColorString : whiteSpaceString);
@@ -75,4 +75,4 @@ public static string GetQRCode(string plainText, int pixelsPerModule, string dar
7575
return qrCode.GetGraphic(pixelsPerModule, darkColorString, whiteSpaceString, drawQuietZones, endOfLine);
7676
}
7777
}
78-
}
78+
}

QRCoder/PayloadGenerator.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ public enum Authentication
5353
{
5454
WEP,
5555
WPA,
56-
nopass
56+
nopass,
57+
WPA2
5758
}
5859
}
5960

@@ -311,7 +312,7 @@ public class Url : Payload
311312
private readonly string url;
312313

313314
/// <summary>
314-
/// Generates a link. If not given, http/https protocol will be added.
315+
/// Generates a link. If the protocol is not specified, the http protocol will be added.
315316
/// </summary>
316317
/// <param name="url">Link url target</param>
317318
public Url(string url)
@@ -321,7 +322,7 @@ public Url(string url)
321322

322323
public override string ToString()
323324
{
324-
return (!this.url.StartsWith("http") ? "http://" + this.url : this.url);
325+
return (!this.url.StartsWith("http", StringComparison.OrdinalIgnoreCase) ? "http://" + this.url : this.url);
325326
}
326327
}
327328

@@ -2012,6 +2013,7 @@ private void ProcessCommonFields(StringBuilder sb)
20122013
}
20132014
string strippedSecret = Secret.Replace(" ", "");
20142015
string escapedIssuer = null;
2016+
string escapedLabel = null;
20152017
string label = null;
20162018

20172019
if (!String40Methods.IsNullOrWhiteSpace(Issuer))
@@ -2023,18 +2025,22 @@ private void ProcessCommonFields(StringBuilder sb)
20232025
escapedIssuer = Uri.EscapeDataString(Issuer);
20242026
}
20252027

2026-
if (!String40Methods.IsNullOrWhiteSpace(Label) && Label.Contains(":"))
2028+
if (!String40Methods.IsNullOrWhiteSpace(Label))
20272029
{
2028-
throw new Exception("Label must not have a ':'");
2030+
if (Label.Contains(":"))
2031+
{
2032+
throw new Exception("Label must not have a ':'");
2033+
}
2034+
escapedLabel = Uri.EscapeDataString(Label);
20292035
}
20302036

2031-
if (Label != null && Issuer != null)
2037+
if (escapedLabel != null && escapedIssuer != null)
20322038
{
2033-
label = Issuer + ":" + Label;
2039+
label = escapedIssuer + ":" + escapedLabel;
20342040
}
2035-
else if (Issuer != null)
2041+
else if (escapedIssuer != null)
20362042
{
2037-
label = Issuer;
2043+
label = escapedIssuer;
20382044
}
20392045

20402046
if (label != null)

QRCoder/PostscriptQRCode.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0 || NET6_0_WINDOWS
1+
#if !NETSTANDARD1_3
22
using System;
33
using System.Drawing;
44
using static QRCoder.QRCodeGenerator;
55

66
namespace QRCoder
77
{
88

9-
#if NET6_0_WINDOWS
10-
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
11-
#endif
129
public class PostscriptQRCode : AbstractQRCode, IDisposable
1310
{
1411
/// <summary>
@@ -143,9 +140,6 @@ sc sc scale
143140
";
144141
}
145142

146-
#if NET6_0_WINDOWS
147-
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
148-
#endif
149143
public static class PostscriptQRCodeHelper
150144
{
151145
public static string GetQRCode(string plainText, int pointsPerModule, string darkColorHex, string lightColorHex, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, bool drawQuietZones = true, bool epsFormat = false)
@@ -157,5 +151,4 @@ public static string GetQRCode(string plainText, int pointsPerModule, string dar
157151
}
158152
}
159153
}
160-
161154
#endif

QRCoder/SvgQRCode.cs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0 || NET6_0_WINDOWS
1+
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0_OR_GREATER
22
using QRCoder.Extensions;
33
using System;
44
using System.Collections;
@@ -11,9 +11,6 @@
1111

1212
namespace QRCoder
1313
{
14-
#if NET6_0_WINDOWS
15-
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
16-
#endif
1714
public class SvgQRCode : AbstractQRCode, IDisposable
1815
{
1916
/// <summary>
@@ -270,13 +267,16 @@ public class SvgLogo
270267
private object _logoRaw;
271268
private bool _isEmbedded;
272269

273-
270+
#if NETFRAMEWORK || NETSTANDARD2_0 || NET5_0 || NET6_0_WINDOWS
274271
/// <summary>
275272
/// Create a logo object to be used in SvgQRCode renderer
276273
/// </summary>
277274
/// <param name="iconRasterized">Logo to be rendered as Bitmap/rasterized graphic</param>
278275
/// <param name="iconSizePercent">Degree of percentage coverage of the QR code by the logo</param>
279276
/// <param name="fillLogoBackground">If true, the background behind the logo will be cleaned</param>
277+
#if NET6_0_WINDOWS
278+
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
279+
#endif
280280
public SvgLogo(Bitmap iconRasterized, int iconSizePercent = 15, bool fillLogoBackground = true)
281281
{
282282
_iconSizePercent = iconSizePercent;
@@ -285,14 +285,15 @@ public SvgLogo(Bitmap iconRasterized, int iconSizePercent = 15, bool fillLogoBac
285285
using (var bitmap = new Bitmap(iconRasterized))
286286
{
287287
bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
288-
_logoData = Convert.ToBase64String(ms.GetBuffer(), Base64FormattingOptions.None);
288+
_logoData = Convert.ToBase64String(ms.GetBuffer(), 0, (int)ms.Length, Base64FormattingOptions.None);
289289
}
290290
}
291291
_mediaType = MediaType.PNG;
292292
_fillLogoBackground = fillLogoBackground;
293293
_logoRaw = iconRasterized;
294294
_isEmbedded = false;
295295
}
296+
#endif
296297

297298
/// <summary>
298299
/// Create a logo object to be used in SvgQRCode renderer
@@ -311,6 +312,22 @@ public SvgLogo(string iconVectorized, int iconSizePercent = 15, bool fillLogoBac
311312
_isEmbedded = iconEmbedded;
312313
}
313314

315+
/// <summary>
316+
/// Create a logo object to be used in SvgQRCode renderer
317+
/// </summary>
318+
/// <param name="iconRasterized">Logo to be rendered as PNG</param>
319+
/// <param name="iconSizePercent">Degree of percentage coverage of the QR code by the logo</param>
320+
/// <param name="fillLogoBackground">If true, the background behind the logo will be cleaned</param>
321+
public SvgLogo(byte[] iconRasterized, int iconSizePercent = 15, bool fillLogoBackground = true)
322+
{
323+
_iconSizePercent = iconSizePercent;
324+
_logoData = Convert.ToBase64String(iconRasterized, Base64FormattingOptions.None);
325+
_mediaType = MediaType.PNG;
326+
_fillLogoBackground = fillLogoBackground;
327+
_logoRaw = iconRasterized;
328+
_isEmbedded = false;
329+
}
330+
314331
/// <summary>
315332
/// Returns the raw logo's data
316333
/// </summary>
@@ -379,9 +396,6 @@ public enum MediaType : int
379396
}
380397
}
381398

382-
#if NET6_0_WINDOWS
383-
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
384-
#endif
385399
public static class SvgQRCodeHelper
386400
{
387401
public static string GetQRCode(string plainText, int pixelsPerModule, string darkColorHex, string lightColorHex, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, bool drawQuietZones = true, SizingMode sizingMode = SizingMode.WidthHeightAttribute, SvgLogo logo = null)

0 commit comments

Comments
 (0)