[v4,1/2] fff-web: Fix two bugs in wifiscan.html

Submitted by Adrian Schmutzler on Jan. 21, 2018, 2:54 p.m.

Details

Message ID 1516546470-2842-1-git-send-email-freifunk@adrianschmutzler.de
State Accepted
Headers show

Commit Message

Adrian Schmutzler Jan. 21, 2018, 2:54 p.m.
Bug 1: If devices with hidden SSID are present, the matched
SSID in the awk contains the newline (="unknown\n\t"). This
destroys the table after the sort.

Bug 2: If SSIDs contain ampersands (yes, people do that),
they are now converted to &.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>

Reviewed-by: Tim Niemeyer <tim@tn-x.org>

----

Changes in v2:
- none

Changes in v3:
- Use Tim's preferred regex

Changes in v4:
None
---
 src/packages/fff/fff-web/files/www/ssl/cgi-bin/wifiscan.html | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/packages/fff/fff-web/files/www/ssl/cgi-bin/wifiscan.html b/src/packages/fff/fff-web/files/www/ssl/cgi-bin/wifiscan.html
index a235159..378896e 100755
--- a/src/packages/fff/fff-web/files/www/ssl/cgi-bin/wifiscan.html
+++ b/src/packages/fff/fff-web/files/www/ssl/cgi-bin/wifiscan.html
@@ -18,8 +18,8 @@ 
 <%
 iwinfo w2mesh scan |\
 	awk -v RS='' \
-	'{r = gensub(/.*Address: ([0-9A-F:]*)?.*ESSID: "?(unknown|[^"]*)"?.*Mode: ([^ ]*).*Channel: ([0-9]*).*Signal: (-[0-9]*) dBm.*Encryption: ([^"]*).*/, \
-	"<!-- \\5 --><tr><td>\\2</td><td>\\4</td><td>\\5 dBm</td><td>\\3</td><td>\\1</td><td>\\6</td></tr>", "g"); print r;}' | sort -n
+	'{r = gensub(/.*Address: ([0-9A-F:]*)?.*ESSID: "?([^"\n]*)"?.*Mode: ([^ ]*).*Channel: ([0-9]*).*Signal: (-[0-9]*) dBm.*Encryption: ([^"]*).*/, \
+	"<!-- \\5 --><tr><td>\\2</td><td>\\4</td><td>\\5 dBm</td><td>\\3</td><td>\\1</td><td>\\6</td></tr>", "g"); print r;}' | sort -n | sed 's#&#\&amp;#'
 	# The HTML comment contains the signal quality to allow sorting
 %>
 	</table>

Comments

Tim Niemeyer Jan. 28, 2018, 11:54 a.m.
Hi

Am Sonntag, den 21.01.2018, 15:54 +0100 schrieb Adrian Schmutzler:
> Bug 1: If devices with hidden SSID are present, the matched
> SSID in the awk contains the newline (="unknown\n\t"). This
> destroys the table after the sort.
> 
> Bug 2: If SSIDs contain ampersands (yes, people do that),
> they are now converted to &amp;.
> 
> Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> 
> Reviewed-by: Tim Niemeyer <tim@tn-x.org>
> 
> ----
Ein Strich zu viel. Patchwork hat das nicht als Ende von der Commit-
Message interpretiert.

Ansonsten: Applied.

Tim

> Changes in v2:
> - none
> 
> Changes in v3:
> - Use Tim's preferred regex
> 
> Changes in v4:
> None
> ---
>  src/packages/fff/fff-web/files/www/ssl/cgi-bin/wifiscan.html | 4 ++-
> -
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/packages/fff/fff-web/files/www/ssl/cgi-
> bin/wifiscan.html b/src/packages/fff/fff-web/files/www/ssl/cgi-
> bin/wifiscan.html
> index a235159..378896e 100755
> --- a/src/packages/fff/fff-web/files/www/ssl/cgi-bin/wifiscan.html
> +++ b/src/packages/fff/fff-web/files/www/ssl/cgi-bin/wifiscan.html
> @@ -18,8 +18,8 @@
>  <%
>  iwinfo w2mesh scan |\
>  	awk -v RS='' \
> -	'{r = gensub(/.*Address: ([0-9A-F:]*)?.*ESSID:
> "?(unknown|[^"]*)"?.*Mode: ([^ ]*).*Channel: ([0-9]*).*Signal: (-[0-
> 9]*) dBm.*Encryption: ([^"]*).*/, \
> -	"<!-- \\5 --><tr><td>\\2</td><td>\\4</td><td>\\5
> dBm</td><td>\\3</td><td>\\1</td><td>\\6</td></tr>", "g"); print r;}'
> | sort -n
> +	'{r = gensub(/.*Address: ([0-9A-F:]*)?.*ESSID:
> "?([^"\n]*)"?.*Mode: ([^ ]*).*Channel: ([0-9]*).*Signal: (-[0-9]*)
> dBm.*Encryption: ([^"]*).*/, \
> +	"<!-- \\5 --><tr><td>\\2</td><td>\\4</td><td>\\5
> dBm</td><td>\\3</td><td>\\1</td><td>\\6</td></tr>", "g"); print r;}'
> | sort -n | sed 's#&#\&amp;#'
>  	# The HTML comment contains the signal quality to allow
> sorting
>  %>
>  	</table>
> -- 
> 2.7.4
>