diff --git a/buildroot b/buildroot index 3f42ebb39..8cf4f17c2 160000 --- a/buildroot +++ b/buildroot @@ -1 +1 @@ -Subproject commit 3f42ebb39708531f493e962a81499aaecb64e97c +Subproject commit 8cf4f17c2a4eeeb0250c90e993de77dd2fad15ea diff --git a/package/prudynt-t/files/prudyntcfg.awk b/package/prudynt-t/files/prudyntcfg.awk index d50d10144..341b1e68c 100644 --- a/package/prudynt-t/files/prudyntcfg.awk +++ b/package/prudynt-t/files/prudyntcfg.awk @@ -1,126 +1,152 @@ #!/usr/bin/awk -f -# write line if y is set, it's commented out -function w(y){ - for(i=0;i=x;d--){ - u=""; - for(i=d;i>0;i--){u=u"\t"} - g[h++]=u"};";u="" - } + u=_i(d); + _e(u"};"); + u="" + } + _s(128); } # split line by char -function a(l){ - split(l,c,""); +function _a(){ for(i=1;i<=length($0);i++){ - s(c[i]); - } -} -# analyze char -function s(c){ - if(and(o,4)&&c!="\""){ - # everything is allowed in quotation marks - k=k""c; - }else if(c==":"||c=="="){ - # here we set value flag - o=or(o,1);t=k;k=""; - }else if(c=="{"){ - if(!and(o,2)){ - # section opener, current key(k) = this(t) - d++; - if(length(p)>0){ - p=p"."t;k="";t="" + c=substr($0,i,1); + if(_q(4)&&c!="\""){ + # everything is allowed in quotation marks + k=k""c; + }else if(c==":"||c=="="){ + # here we set value flag + _s(1);t=k;k=""; + }else if(c=="{"){ + if(!_q(2)){ + # section opener, current key(k) = this(t) + d++; + if(p){ + p=p"."t;k="";t="" + }else{ + p=t;t="" + } }else{ - p=t;t="" - } - }else{ - # object opener in an array - } - }else if(c=="}"){ - if(!and(o,2)){ - # section closer - # - # if the section is closed and the value should be set but does not exist. - # we insert a new line here - if(s==p&&f~"^set$"&&(!and(o,128))){ - if(length(v)){g[h++]=w()}else{o=or(o,128)} + # object opener in an array } - if(s~"^"p".*$"&&f~"^set$"&&(!and(o,128))){ - b(); - } - # remove last path element and cleanup current(t) - if(sub(/\.[[:alnum:]]+$/,"",p)==0){ - p="" + }else if(c=="}"){ + if(!_q(2)){ + # section closer + # + # if the section is closed and the value should be set but does not exist. + # we insert a new line here + if(s==p&&f~"^set$"&&(!_q(128))){ + if(v){_e(_w())} + } + if(s~"^"p"\\..*$"&&f~"^set$"&&(!_q(128))){ + if(v){_b()} + } + # remove last path element and cleanup current(t) + if(sub(/\.[[:alnum:]]+$/,"",p)==0){ + p="" + } + t="";d-- + } else { + # object closer in an array } - t="";d-- - } else { - # object closer in an array + }else if(c=="("){ + # array opener + _s(2); + }else if(c==")"){ + # array closer + _i(2); + }else if(_q(1)==1&&c=="\""){ + # opening / closing quotation marks, assign string value on close + if(!_q(4)){_s(4);k=""}else{_u(4);r="\""k"\"";k=""} + }else if(_q(1)&&c==";"){ + # value terminator ';' + if(length(r)==0){r=k;k=""}; + }else if(_q(1)&&c=="#"){ + # comment at the end of the line + _s(8); + }else if(match(c,"[^[:space:]]")){ + k=k""c; } - }else if(c=="("){ - # array opener - o=or(o,2); - }else if(c==")"){ - # array closer - o=xor(o,2); - }else if(and(o,1)==1&&c=="\""){ - # opening / closing quotation marks, assign string value on close - if(!and(o,4)){o=or(o,4);k=""}else{o=xor(o,4);r="\""k"\"";k=""} - }else if(and(o,1)&&c==";"){ - # value terminator ';' - if(length(r)==0){r=k;k=""}; - }else if(and(o,1)&&c=="#"){ - # comment at the end of the line - o=or(o,8); - }else if(match(c,"[^[:space:]]")){ - k=k""c; } } -function p(l) { - _m=(s==p&&match(l,"^[[:space:]]*#.*"e".*:.*")); - if(length(l)&&((!match(l,"^[[:space:]]*#")&&!match(l,"^\s*$")&&!match(l,"^version.*$"))||_m)){ +function _p() { + # match key/value line in section also if commented out + b=(s==p&&match($0,"^[[:space:]]*#[[:space:]]*"e"[[:space:]]*:.*")); + if(length($0)&&((!match($0,"^[[:space:]]*#")&&!match($0,"^\\s*$")&&!match($0,"^version.*$"))||b)){ # check if line is commented out - if(_m){sub("#[[:space:]]", "",l)} + if(b){sub("#([[:space:]]*)","",$0)} # value mode reset on each line - if(and(o,1)){o=xor(o,1)} # comment reset on each line - if(and(o,8)){o=xor(o,8)} + _u(9); # current (k), value(r), comment(n) rest on each line k="";r="";n=""; - # call a to analyze character - a(l); + # call _a to analyze line + _a(); # if k is not empty here, it must be a (unterminated) value or comment - if(length(k)>0){if(and(o,8)==8){n=k}else{r=k}} + if(length(k)>0){if(_q(8)){n=k}else{r=k}} # exact section and value match - if(f~"^list$"&&!_m&&(p==s||p~"^"s".*$"||length(s)==0)&&length(p)&&length(t)&&length(r)){ - o=or(o,128); + if(f~"^list$"&&!b&&(p==s||p~"^"s"\\..*$"||!s)&&p&&t&&r){ print(p"."t"="r) } if(s==p&&e==t) { - if(f~"^get$"&&!_m){o=or(o,256);print(r);exit;} - if(f~"^set$"){if(length(v)||_m){$0=w()}else{o=or(o,128)}} - if(f~"^unset$"){$0=w(1)} + if(f~"^get$"&&!b){_s(256);print(r);exit;} + if(f~"^set$"){if(v||b){$0=_w()}} + if(f~"^unset$"){$0=_w(1)} } } } @@ -128,12 +154,13 @@ function p(l) { BEGIN { f=ARGV[1]; s=ARGV[2]; - if((f~"^[g|s]et|unset$"&&ARGV[2])){ + if((f~"^(get|set|unset)$"&&s)){ i=split(s,j,"."); - e=j[i];sub(/\.[[:alnum:]]+$/,"",s) + e=j[i]; + sub(/\.[[:alnum:]_]+$/,"",s) } v=ARGV[3]; - if(!ARGV[1]||(f~"^[g|s]et|unset$"&&!ARGV[2])||i==1){ + if(!f||(!(f~"^(get|set|unset|list)$"))||(!(f~"^list$")&&i==1&&s)){ print "prudynt configuration helper v0.1"; print ""; print "Usage [get|set|list|unset]
. "; @@ -143,24 +170,22 @@ BEGIN { print "\t\tif value is not provided but setting exists as comment, it will be uncomment"; print "\tlist\tlist all configured . Can be limited by providing a
"; print "\tunset\tcomment a if exists"; - o=or(o,320);f=""; - exit; + f="";_s(320);exit; } + for (i=ARGC;i>2;i--){ARGC--} ARGV[1]="/etc/prudynt.cfg"; } -{if(!and(o,256)){p($0);g[h++]=$0}} +{if(o<256){if(o<128){_p()};_e($0)}} END{ - if(f~"^set$"&&(!and(o,128))){ + if(f~"^set$"&&(!_q(128))){ # main section does not exists, we need to create - g[h++];b() + _e("");_b() } - if(f~"^set$|^unset$") { - for(i=0;iARGV[1] - } + if(_q(128)) { + print g>ARGV[1] } - if((and(o,256)||and(o,128))&&!and(o,64)){ + if((_q(128)||_q(256))&&f){ exit 0 } exit 1 diff --git a/package/thingino-webui/files/var/www/x/tool-file-manager.cgi b/package/thingino-webui/files/var/www/x/tool-file-manager.cgi index a7e691580..3a14ee65e 100755 --- a/package/thingino-webui/files/var/www/x/tool-file-manager.cgi +++ b/package/thingino-webui/files/var/www/x/tool-file-manager.cgi @@ -43,7 +43,7 @@ IFS=$'\n' for line in $lsfiles; do echo "" # skip . - [ -n "$(echo $line | grep \s\./$)" ] && continue + echo $line | grep -q ' \./$' && continue name=${line##* }; line=${line% *} path=$(echo "$dir/$name" | sed s#^//#/#)