Skip to content

Commit

Permalink
Merge pull request #41 from microsoft/fix/removeCharacters
Browse files Browse the repository at this point in the history
fix: removes call to addcslashes in getStringValue() functions
  • Loading branch information
Ndiritu authored Feb 10, 2025
2 parents e145105 + de2e6d1 commit f7097a1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/serialization/form/src/FormParseNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function getChildNode(string $identifier): ?FormParseNode
public function getStringValue(): ?string
{
return is_string($this->node) && !$this->isNull()
? urldecode(addcslashes($this->node, "\\\t\r\n"))
? urldecode($this->node)
: null;
}
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/serialization/json/src/JsonParseNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function getChildNode(string $identifier): ?ParseNode {
* @inheritDoc
*/
public function getStringValue(): ?string {
return is_string($this->jsonNode) ? addcslashes($this->jsonNode, "\\\r\n") : null;
return is_string($this->jsonNode) ? $this->jsonNode : null;
}

/**
Expand Down
9 changes: 9 additions & 0 deletions packages/serialization/json/tests/JsonParseNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,15 @@ public function testGetStringValue(): void{
$this->assertEquals('Silas Kenneth was here', $expected);
}

/**
*/
public function testGetStringValueWithSlashAndWhitespace(): void
{
$this->parseNode = new JsonParseNode('\ This is a test with a tab at then and slash at the beginning \t.');
$expected = $this->parseNode->getStringValue();
$this->assertEquals('\ This is a test with a tab at then and slash at the beginning \t.', $expected);
}

public function testGetChildNode(): void {
$this->stream->rewind();
$this->parseNode = (new JsonParseNodeFactory())->getRootParseNode('application/json', $this->stream);
Expand Down

0 comments on commit f7097a1

Please sign in to comment.