All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] package/plg-utils: escape \ in generated legal-info
@ 2021-02-06  8:51 Yann E. MORIN
  2021-02-07  9:35 ` Peter Korsgaard
  0 siblings, 1 reply; 7+ messages in thread
From: Yann E. MORIN @ 2021-02-06  8:51 UTC (permalink / raw)
  To: buildroot

In the output of legal-info, which is JSON-formatted, we include the
CPI_ID (when it is valid).

For xerces, the CPE_IS contains two sequences aof \+ (which is exactly
what is present in the NIST DB, [0]).

However, in JSON, like in C, \ escapes the following character; only a
very limited set of characters are valid to escape: " \ / b f n r t u.
Escaping any other character is invalid. Conformant JSON parser will
choke on invalid sequences, and so does not the json python module:

      File "/usr/lib/python2.7/json/decoder.py", line 380, in raw_decode
        obj, end = self.scan_once(s, idx)
    ValueError: Invalid \escape: line 1 column 608554 (char 608553)

We fix that be globally escaping \ in our json output, in the generic
sanitsing macro.

[0] https://nvd.nist.gov/products/cpe/detail/645?namingFormat=2.3&orderBy=CPEURI&keyword=xerces&status=FINAL

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
---
 package/pkg-utils.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/package/pkg-utils.mk b/package/pkg-utils.mk
index b50d459075..ae3c7f9da9 100644
--- a/package/pkg-utils.mk
+++ b/package/pkg-utils.mk
@@ -171,8 +171,9 @@ endef
 clean-json = $(strip \
 	$(subst $(comma)},}, $(subst $(comma)$(space)},$(space)}, \
 	$(subst $(comma)],], $(subst $(comma)$(space)],$(space)], \
+	$(subst \,\\, \
 		$(strip $(1)) \
-	)))) \
+	))))) \
 )
 
 ifeq ($(BR2_PER_PACKAGE_DIRECTORIES),y)
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-02-07 14:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-06  8:51 [Buildroot] [PATCH] package/plg-utils: escape \ in generated legal-info Yann E. MORIN
2021-02-07  9:35 ` Peter Korsgaard
2021-02-07 11:28   ` Yann E. MORIN
2021-02-07 12:18     ` Peter Korsgaard
2021-02-07 13:17       ` Yann E. MORIN
2021-02-07 13:33       ` Yann E. MORIN
2021-02-07 14:21         ` Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.