Fix: reject invalid server IPs (CIDR) in Conditional Forwarding table - #3833
Fix: reject invalid server IPs (CIDR) in Conditional Forwarding table#3833amonkarsidhant wants to merge 1 commit into
Conversation
The Server IP field in the Conditional Forwarding table accepted invalid values like CIDR notation (e.g., 192.168.1.0/24) due to two bugs: 1. The footer row's save button was never disabled by input validation because its parent <th> lacked the 'actions' class that the validation selector expects. 2. The addRevServer() and saveRecord() functions only checked for empty fields without validating the IP format. Fix: - Add class="actions" to the footer row's <th> so the validation selector can find and disable the save button. - Add IP format validation in addRevServer() and saveRecord() using the existing utils.validateIPv4WithPort() and utils.validateIPv6WithPort() functions, which already reject CIDR notation. Fixes pi-hole#3829 Signed-off-by: Sidhant Aneesh <sidhant@amonkar.dev>
|
The original issue was actually a bad validation function, that allowed
This is not the case. The table cell has the The class is set using datatables web/scripts/js/settings-dns.js Line 177 in b2a4078 The values type on the table footer were validated, but using a broken function.
The validation function was broken. Adding the validation here (using that broken function) wouldn't change anything. This would take effect now that the validation function has been fixed, but the values will already be validated, so this is not necessary. |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
|
The conflicts here are context only: Worth noting that the |

Fixes #3829
What does this PR aim to accomplish?
Reject invalid server IPs (CIDR notation like
192.168.1.0/24) in the Conditional Forwarding table. Previously, the Server IP field accepted these invalid values due to two bugs.How does this PR accomplish the above?
Fix footer row save button not being disabled (
settings-dns.lp): Addedclass=actionsto the footer row's<th>containing the save button. The validation handler usesjavascript\n.siblings(.actions).find(.saveRevServers).prop(disabled, true);\nbut the footer row's<th>lacked theactionsclass, so the button was never disabled.Add server-side IP validation (
scripts/js/settings-dns.js): Added IP format validation inaddRevServer()andsaveRecord()using existingutils.validateIPv4WithPort()andutils.validateIPv6WithPort()functions, which already reject CIDR notation.Link documentation PRs if any are needed to support this PR
N/A
By submitting this pull request, I confirm the following:
developmentbranch