Message ID | 20240404124329.768546-3-thomas.perale@mind.be |
---|---|
State | New |
Headers | show |
Series | Support SBOM in CycloneDX format | expand |
Thomas, All, On 2024-04-04 14:43 +0200, Thomas Perale via buildroot spake thusly: > This patch introduces two new macros: > > - urlencode > - urldecode > > URL encoding consists of converting ASCII characters into > a percent symbol followed by a two digit hexadecimal code. > And the other way around for URL decoding. > > The macros encode/decode a string passed as an argument by > escaping the following characters: > > - '%' is replaced by %25 > - 'space' is replaced by %20 > > The characters covered by this patch is non exhaustive. Not sure what you meant with this sentence... Can you elaborate? Or did you mean that we can add more chars in the future? Regards, Yann E. MORIN. > Because the Make language treats spaces as different entry of a list, > the aim of those macros is to provide a well known encoding method > to escape text containing spaces into a string that won't be > treated as a list by the Make language. > > Signed-off-by: Thomas Perale <thomas.perale@mind.be> > --- > package/pkg-utils.mk | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/package/pkg-utils.mk b/package/pkg-utils.mk > index 723bbe4e24..b8cfb85fca 100644 > --- a/package/pkg-utils.mk > +++ b/package/pkg-utils.mk > @@ -329,3 +329,15 @@ define NXP_EXTRACT_HELPER > find $(@D)/$(basename $(notdir $(1))) -mindepth 1 -maxdepth 1 -exec mv {} $(@D) \; > rmdir $(@D)/$(basename $(notdir $(1))) > endef > + > +# urlencode -- returns an url encoded string. > +# - encode % into %25 > +# - encode spaces into %20 > +# > +# $(1): text > +urlencode = $(subst $(space),%20,$(subst %,%25,$(1))) > + > +# urldecode -- decode an url encoded string. > +# > +# $(1): text > +urldecode = $(subst %25,%,$(subst %20,$(space),$(1))) > -- > 2.44.0 > > _______________________________________________ > buildroot mailing list > buildroot@buildroot.org > https://lists.buildroot.org/mailman/listinfo/buildroot
On 07/04/2024 19:44, Yann E. MORIN wrote: > Thomas, All, > > On 2024-04-04 14:43 +0200, Thomas Perale via buildroot spake thusly: >> This patch introduces two new macros: >> >> - urlencode >> - urldecode >> >> URL encoding consists of converting ASCII characters into >> a percent symbol followed by a two digit hexadecimal code. >> And the other way around for URL decoding. >> >> The macros encode/decode a string passed as an argument by >> escaping the following characters: >> >> - '%' is replaced by %25 >> - 'space' is replaced by %20 >> >> The characters covered by this patch is non exhaustive. > > Not sure what you meant with this sentence... Can you elaborate? It means that not all characters that normally are urlencoded (like /, :, #) are handled by this patch. > Or did you mean that we can add more chars in the future? So yes, that. Regards, Arnout > > Regards, > Yann E. MORIN. > >> Because the Make language treats spaces as different entry of a list, >> the aim of those macros is to provide a well known encoding method >> to escape text containing spaces into a string that won't be >> treated as a list by the Make language. >> >> Signed-off-by: Thomas Perale <thomas.perale@mind.be> >> --- >> package/pkg-utils.mk | 12 ++++++++++++ >> 1 file changed, 12 insertions(+) >> >> diff --git a/package/pkg-utils.mk b/package/pkg-utils.mk >> index 723bbe4e24..b8cfb85fca 100644 >> --- a/package/pkg-utils.mk >> +++ b/package/pkg-utils.mk >> @@ -329,3 +329,15 @@ define NXP_EXTRACT_HELPER >> find $(@D)/$(basename $(notdir $(1))) -mindepth 1 -maxdepth 1 -exec mv {} $(@D) \; >> rmdir $(@D)/$(basename $(notdir $(1))) >> endef >> + >> +# urlencode -- returns an url encoded string. >> +# - encode % into %25 >> +# - encode spaces into %20 >> +# >> +# $(1): text >> +urlencode = $(subst $(space),%20,$(subst %,%25,$(1))) >> + >> +# urldecode -- decode an url encoded string. >> +# >> +# $(1): text >> +urldecode = $(subst %25,%,$(subst %20,$(space),$(1))) >> -- >> 2.44.0 >> >> _______________________________________________ >> buildroot mailing list >> buildroot@buildroot.org >> https://lists.buildroot.org/mailman/listinfo/buildroot >
diff --git a/package/pkg-utils.mk b/package/pkg-utils.mk index 723bbe4e24..b8cfb85fca 100644 --- a/package/pkg-utils.mk +++ b/package/pkg-utils.mk @@ -329,3 +329,15 @@ define NXP_EXTRACT_HELPER find $(@D)/$(basename $(notdir $(1))) -mindepth 1 -maxdepth 1 -exec mv {} $(@D) \; rmdir $(@D)/$(basename $(notdir $(1))) endef + +# urlencode -- returns an url encoded string. +# - encode % into %25 +# - encode spaces into %20 +# +# $(1): text +urlencode = $(subst $(space),%20,$(subst %,%25,$(1))) + +# urldecode -- decode an url encoded string. +# +# $(1): text +urldecode = $(subst %25,%,$(subst %20,$(space),$(1)))
This patch introduces two new macros: - urlencode - urldecode URL encoding consists of converting ASCII characters into a percent symbol followed by a two digit hexadecimal code. And the other way around for URL decoding. The macros encode/decode a string passed as an argument by escaping the following characters: - '%' is replaced by %25 - 'space' is replaced by %20 The characters covered by this patch is non exhaustive. Because the Make language treats spaces as different entry of a list, the aim of those macros is to provide a well known encoding method to escape text containing spaces into a string that won't be treated as a list by the Make language. Signed-off-by: Thomas Perale <thomas.perale@mind.be> --- package/pkg-utils.mk | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.44.0