From 3fbeac8a35dbaa6076666e2786095729d5e93ecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Z=C3=BCnd?= Date: Tue, 24 Sep 2024 14:19:33 +0200 Subject: [PATCH] Editorial: Extract 'validate base64 VLQ groupings' algorithm --- source-map.bs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/source-map.bs b/source-map.bs index 5460953..a0b906d 100644 --- a/source-map.bs +++ b/source-map.bs @@ -472,18 +472,7 @@ To decode source map mappings given a [=string=] |mappings|, a [=list=] of [=strings=] |names|, and a [=list=] of [=decoded source|decoded sources=] |sources|, run the following steps: -1. If |mappings| is not an [=ASCII string=], throw an error. -1. If |mappings| contains any [=code unit=] other than: - - U+002C (,) or U+003B (;); - - U+0030 (0) to U+0039 (9); - - U+0041 (A) to U+005A (Z); - - U+0061 (a) to U+007A (z); - - U+002B (+), U+002F (/) - - NOTE: These are the valid [[base64]] characters (excluding the padding character `=`), together - with `,` and `;`. - - then throw an error. +1. [=Validate base64 VLQ groupings=] with |mappings|. 1. Let |decodedMappings| be a new empty [=list=]. 1. Let |groups| be the result of [=strictly split|strictly splitting=] |mappings| on `;`. 1. Let |generatedLine| be 0. @@ -545,6 +534,20 @@ sources=] |sources|, run the followi 1. Increase |generatedLine| by 1. 1. Return |decodedMappings|. +To validate base64 VLQ groupings from a [=string=] |groupings|, run the following steps: +1. If |groupings| is not an [=ASCII string=], throw an error. +1. If |groupings| contains any [=code unit=] other than: + - U+002C (,) or U+003B (;); + - U+0030 (0) to U+0039 (9); + - U+0041 (A) to U+005A (Z); + - U+0061 (a) to U+007A (z); + - U+002B (+), U+002F (/) + + NOTE: These are the valid [[base64]] characters (excluding the padding character `=`), together + with `,` and `;`. + + then throw an error. + To decode a base64 VLQ from a [=string=] |segment| given a [=position variable=] |position|, run the following steps: 1. If |position| points to the end of |segment|, return null.