fw4: ensure to capitalize weekday names
authorJo-Philipp Wich <jo@mein.io>
Wed, 30 Mar 2022 14:49:22 +0000 (16:49 +0200)
committerJo-Philipp Wich <jo@mein.io>
Wed, 30 Mar 2022 14:52:23 +0000 (16:52 +0200)
Despite what's being documented in the nftables wiki, nftables does not
actually accept lowercased or abbreviated weekday names, currently failing
with a "Error: Could not parse Day of week of packet reception" error for
expressions such as `meta day { "sunday", "wed" }`.

Work around the problem by explicitly emitting capitalized weekday names
while a more thorough nftables-side solution is being sent upstream.

Ref: https://forum.openwrt.org/t/firewall-time-restrictions-parental-controls-problems/123964
Ref: https://wiki.nftables.org/wiki-nftables/index.php/Matching_packet_metainformation#Matching_by_time
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
root/usr/share/ucode/fw4.uc

index 37d117c589bdf3b93c89a96d1edbfd61d49b8495..8a4277baa8b8cd72fe379ae27f736a22afeea052 100644 (file)
@@ -888,7 +888,7 @@ return {
                        val = lc(val);
 
                        for (let i = 0; i < length(choices); i++)
-                               if (substr(choices[i], 0, length(val)) == val)
+                               if (lc(substr(choices[i], 0, length(val))) == val)
                                        return choices[i];
                }
 
@@ -1280,13 +1280,13 @@ return {
 
                for (let day in to_array(rv.val)) {
                        day = this.parse_enum(day, [
-                               "monday",
-                               "tuesday",
-                               "wednesday",
-                               "thursday",
-                               "friday",
-                               "saturday",
-                               "sunday"
+                               "Monday",
+                               "Tuesday",
+                               "Wednesday",
+                               "Thursday",
+                               "Friday",
+                               "Saturday",
+                               "Sunday"
                        ]);
 
                        if (!day)