Parcourir la source

Fix a potential DivisionByZeroError in templates

Baptiste Jonglez il y a 10 ans
Parent
commit
19f9298832
1 fichiers modifiés avec 2 ajouts et 2 suppressions
  1. 2 2
      templates/results.html

+ 2 - 2
templates/results.html

@@ -25,14 +25,14 @@
   {% endif %}
   {%- endmacro %}
   {% for r in results %}
-  {% if r.probes_sent is not none() and r.probes_received is not none() %}
+  {% if r.probes_sent is not none() and r.probes_received is not none() and r.probes_sent != 0 %}
   {% set packetloss = (100 * (r.probes_sent - r.probes_received) / r.probes_sent) %}
   {% endif %}
   <tr>
     <td>{% if r.avgrtt is not none() %}{{ r.avgrtt|round(2) }} ms{% endif %}</td>
     <td>{% if r.jitter is not none() %}{{ r.jitter|round(2) }} ms{% endif %}</td>
     <td>
-      {% if r.probes_sent is not none() and r.probes_received is not none() %}
+      {% if r.probes_sent is not none() and r.probes_received is not none() and r.probes_sent != 0 %}
       <span class={{ color(packetloss) }}>
         {{ packetloss|round(2) }}%
       </span>