OpenWrt Forum Archive

Topic: Little LUCI fix submit

The content of this topic has been archived on 3 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,

I'm not a developper, but I found a little bug on the web UI when you go in "Router -> Network -> DHCP and DNS -> Static Leases". Everything works well excepted if you want to use Static Lease (MAC address hot swap) [source: http://wiki.openwrt.org/doc/uci/dhcp#st … hot.swap]. You won't be able to put more than one mac address, and the webui won't let you save your changes. Hopefully, there is a little JS script fix :-)

> Bug:
If you enter more than one mac address in those fields, you won't be able to save you config as the WebUI detects a syntax error. Moreover, you will have everything in red. Bwerk

> Explanation:
Fields content are checked via JavaScript (not a good way to do but ... anyway). The function applies a regex on the content and return a code depending the field content is OK or not. In the mac address field, we should be able to define more than one mac address but the current regex does not support it. That's why I purpose this little fix to resolve this problem :-)

> Patch
The concerned file is /www/luci-static/resources/cbi.js and you need to replace this part of code:

        'macaddr': function(v)
        {
                return (v.match(/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/) != null);
        },

by:

        'macaddr': function(v)                        
        {                                             
                return (v.match(/^(([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}\s)*([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/) != null);   
        }, 

> Issue:
This chunk of code may be used somewhere else in the webUI, and other fields using this function to check their content may not be happy to have many mac address instead of one. The best way to fix that is to duplicate this filter (especially used for many mac addresses) and use this specific one on this specific field :-)

I'm quite new with OpenWRT, and I don't know very well the rules of this community. So I post this little patch here, with the secret hope than somebody will integrate it in the dev. As I told you, I'm not a programmer, and I'm lazy to learn all the code submit process ... I'm not even sure if my patch is the good way of fixing this issue, but anyway, I posted my solution by thinking somebody would be happy to find it here :-)

Cheeeers

Thank you!

I am not part of the team (is there such a thing?), but I just try to give you some hints here.

Although LuCI is closely related to OpenWrt, it is a separate project available at: http://luci.subsignal.org/trac

You have a ticket system there, where you can submit your bug that doesn't require prior login (although it is a good practice): http://luci.subsignal.org/trac/newticket

It is probably the best place to describe what you have found and for it to be taken into account.

But don't worry, people in this forum are generally very helpful!

Cheers

Squonk: Fair enough ^^I just reported it then smile

Cheers

The proper way to check a field for a list of mac addresses is to declare the datatype as "list(macaddr)"

The discussion might have continued from here.