Fix single quotes issue with PHP

This commit is contained in:
nashe
2016-03-23 20:56:31 +01:00
parent f7f7d89177
commit 03c0248597
4 changed files with 20 additions and 4 deletions

1
test/curl18.txt Normal file
View File

@@ -0,0 +1 @@
curl google.com --data 'field=don%27t%20you%20like%20quotes'

7
test/php_output18.php Normal file
View File

@@ -0,0 +1,7 @@
<?php
include('vendor/rmccue/requests/library/Requests.php');
Requests::register_autoloader();
$data = array(
'field' => 'don\'t you like quotes'
);
$response = Requests::post('google.com', $headers, $data);

View File

@@ -164,6 +164,14 @@ test('http post with data - php', function (t) {
t.end();
});
test('http post with quotes inside data - php', function (t) {
var curlHttpPostCommand = fs.readFileSync(__dirname + '/curl18.txt', 'utf-8');
var phpCode = curlconverter.toPhp(curlHttpPostCommand);
var goodPhpCode = fs.readFileSync(__dirname + '/php_output18.php', 'utf-8').trim();
t.equal(phpCode, goodPhpCode);
t.end();
});
test('http get with single header - node', function (t) {
var curlHttpPostCommand = fs.readFileSync(__dirname + '/curl8.txt', 'utf-8');
var nodeCode = curlconverter.toNode(curlHttpPostCommand);
@@ -245,4 +253,4 @@ test('http put with file - python', function (t) {
var goodPythonCode = fs.readFileSync(__dirname + '/python_output9.py', 'utf-8');
t.equal(pythonCode, goodPythonCode);
t.end();
});
});