Escape net-snmp unformatted strings, try 2 (#13584)

* Escape net-snmp unformatted strings, try 2

* Add some tests
This commit is contained in:
Tony Murray
2021-11-30 00:12:42 -06:00
committed by GitHub
parent 4a99b798b5
commit 9d2633bf09
3 changed files with 9 additions and 2 deletions

View File

@@ -47,6 +47,13 @@ class SnmpResponseTest extends TestCase
$this->assertEquals(['' => 'IF-MIB::ifDescr'], $response->values());
$this->assertEquals('IF-MIB::ifDescr', $response->value());
$this->assertEquals(['IF-MIB::ifDescr'], $response->table());
// unescaped strings
$response = new SnmpResponse("Q-BRIDGE-MIB::dot1qVlanStaticName[1] = \"default\"\nQ-BRIDGE-MIB::dot1qVlanStaticName[9] = \"\\\\Surrounded\\\\\"");
$this->assertTrue($response->isValid());
$this->assertEquals('default', $response->value());
$this->assertEquals(['Q-BRIDGE-MIB::dot1qVlanStaticName[1]' => 'default', 'Q-BRIDGE-MIB::dot1qVlanStaticName[9]' => '\\Surrounded\\'], $response->values());
$this->assertEquals(['Q-BRIDGE-MIB::dot1qVlanStaticName' => [1 => 'default', 9 => '\\Surrounded\\']], $response->table());
}
public function testMultiLine(): void