PHP cut GET request param
In my PHP application I use this code to get request
$this->request->get
this return all data
Array
(
[rt] => extension/dump
[type] => xls
[controller] => list/product
[s] => administration
[token] => s7KO9PkoPmgpQmZjPQOimTbdKMB85uGa
[filters] => {"_search":true,"nd":1542700897278,"rows":20,"page":1,"sidx":"date_modified","sord":"desc","filters":"{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon
[Eucalyptus"}]}"}] =>
)
However next code cut the data
$this->request->get['filters']
returned only part of data (see the end of 'filters' are removed)
{"_search":true,"nd":1542700897278,"rows":20,"page":1,"sidx":"date_modified","sord":"desc","filters":"
{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon
Is any workaround to get full data inside 'filters'?
Converting object to array is not help
UPDATE:
js console output
{_search: false, nd: 1542700894743, rows: 20, page: 1, sidx: "date_modified", …}
filters: "{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon & Eucalyptus"}]}"
nd: 1542700897278
page: 1
rows: 20
sidx: "date_modified"
sord: "desc"
_search: true
Request URL: http://blablabla&filters={%22_search%22:true,%22nd%22:1542700897278,%22rows%22:20,%22page%22:1,%22sidx%22:%22date_modified%22,%22sord%22:%22desc%22,%22filters%22:%22{%22groupOp%22:%22AND%22,%22rules%22:[{%22field%22:%22name%22,%22op%22:%22cn%22,%22data%22:%22Lemon%20&%20Eucalyptus%22}]}%22}
Request Method: GET
Is it somehow related to ampersand?
php arrays json object request
|
show 3 more comments
In my PHP application I use this code to get request
$this->request->get
this return all data
Array
(
[rt] => extension/dump
[type] => xls
[controller] => list/product
[s] => administration
[token] => s7KO9PkoPmgpQmZjPQOimTbdKMB85uGa
[filters] => {"_search":true,"nd":1542700897278,"rows":20,"page":1,"sidx":"date_modified","sord":"desc","filters":"{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon
[Eucalyptus"}]}"}] =>
)
However next code cut the data
$this->request->get['filters']
returned only part of data (see the end of 'filters' are removed)
{"_search":true,"nd":1542700897278,"rows":20,"page":1,"sidx":"date_modified","sord":"desc","filters":"
{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon
Is any workaround to get full data inside 'filters'?
Converting object to array is not help
UPDATE:
js console output
{_search: false, nd: 1542700894743, rows: 20, page: 1, sidx: "date_modified", …}
filters: "{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon & Eucalyptus"}]}"
nd: 1542700897278
page: 1
rows: 20
sidx: "date_modified"
sord: "desc"
_search: true
Request URL: http://blablabla&filters={%22_search%22:true,%22nd%22:1542700897278,%22rows%22:20,%22page%22:1,%22sidx%22:%22date_modified%22,%22sord%22:%22desc%22,%22filters%22:%22{%22groupOp%22:%22AND%22,%22rules%22:[{%22field%22:%22name%22,%22op%22:%22cn%22,%22data%22:%22Lemon%20&%20Eucalyptus%22}]}%22}
Request Method: GET
Is it somehow related to ampersand?
php arrays json object request
Could you post the actual parameters copied and pasted from your browser's address bar please?
– Scoots
Nov 20 '18 at 8:32
1
Have you tried comparing$this->request->get
and actual$_GET
? Maybe it's your parser that fails?
– Justinas
Nov 20 '18 at 9:04
@Justinas , $_GET["filters"] return the same. Cut result to Lemon... last part is missing
– S.M. Nat
Nov 20 '18 at 9:15
Check your php.ini and tell if value ofmax_value_length
does not exceeds your query string. Also note that query string starts with?
and not with&
– Justinas
Nov 20 '18 at 9:49
1
This really depends on how you're reading / displaying these results. It also seems very strange to have your request parameters HTML encoded. I suspect one or both of "you're viewing it incorrectly" and "something is manipulating the data in a bad way before you read it"
– Phil
Nov 21 '18 at 1:49
|
show 3 more comments
In my PHP application I use this code to get request
$this->request->get
this return all data
Array
(
[rt] => extension/dump
[type] => xls
[controller] => list/product
[s] => administration
[token] => s7KO9PkoPmgpQmZjPQOimTbdKMB85uGa
[filters] => {"_search":true,"nd":1542700897278,"rows":20,"page":1,"sidx":"date_modified","sord":"desc","filters":"{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon
[Eucalyptus"}]}"}] =>
)
However next code cut the data
$this->request->get['filters']
returned only part of data (see the end of 'filters' are removed)
{"_search":true,"nd":1542700897278,"rows":20,"page":1,"sidx":"date_modified","sord":"desc","filters":"
{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon
Is any workaround to get full data inside 'filters'?
Converting object to array is not help
UPDATE:
js console output
{_search: false, nd: 1542700894743, rows: 20, page: 1, sidx: "date_modified", …}
filters: "{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon & Eucalyptus"}]}"
nd: 1542700897278
page: 1
rows: 20
sidx: "date_modified"
sord: "desc"
_search: true
Request URL: http://blablabla&filters={%22_search%22:true,%22nd%22:1542700897278,%22rows%22:20,%22page%22:1,%22sidx%22:%22date_modified%22,%22sord%22:%22desc%22,%22filters%22:%22{%22groupOp%22:%22AND%22,%22rules%22:[{%22field%22:%22name%22,%22op%22:%22cn%22,%22data%22:%22Lemon%20&%20Eucalyptus%22}]}%22}
Request Method: GET
Is it somehow related to ampersand?
php arrays json object request
In my PHP application I use this code to get request
$this->request->get
this return all data
Array
(
[rt] => extension/dump
[type] => xls
[controller] => list/product
[s] => administration
[token] => s7KO9PkoPmgpQmZjPQOimTbdKMB85uGa
[filters] => {"_search":true,"nd":1542700897278,"rows":20,"page":1,"sidx":"date_modified","sord":"desc","filters":"{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon
[Eucalyptus"}]}"}] =>
)
However next code cut the data
$this->request->get['filters']
returned only part of data (see the end of 'filters' are removed)
{"_search":true,"nd":1542700897278,"rows":20,"page":1,"sidx":"date_modified","sord":"desc","filters":"
{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon
Is any workaround to get full data inside 'filters'?
Converting object to array is not help
UPDATE:
js console output
{_search: false, nd: 1542700894743, rows: 20, page: 1, sidx: "date_modified", …}
filters: "{"groupOp":"AND","rules":[{"field":"name","op":"cn","data":"Lemon & Eucalyptus"}]}"
nd: 1542700897278
page: 1
rows: 20
sidx: "date_modified"
sord: "desc"
_search: true
Request URL: http://blablabla&filters={%22_search%22:true,%22nd%22:1542700897278,%22rows%22:20,%22page%22:1,%22sidx%22:%22date_modified%22,%22sord%22:%22desc%22,%22filters%22:%22{%22groupOp%22:%22AND%22,%22rules%22:[{%22field%22:%22name%22,%22op%22:%22cn%22,%22data%22:%22Lemon%20&%20Eucalyptus%22}]}%22}
Request Method: GET
Is it somehow related to ampersand?
php arrays json object request
php arrays json object request
edited Nov 21 '18 at 1:43
asked Nov 20 '18 at 8:24
S.M. Nat
617
617
Could you post the actual parameters copied and pasted from your browser's address bar please?
– Scoots
Nov 20 '18 at 8:32
1
Have you tried comparing$this->request->get
and actual$_GET
? Maybe it's your parser that fails?
– Justinas
Nov 20 '18 at 9:04
@Justinas , $_GET["filters"] return the same. Cut result to Lemon... last part is missing
– S.M. Nat
Nov 20 '18 at 9:15
Check your php.ini and tell if value ofmax_value_length
does not exceeds your query string. Also note that query string starts with?
and not with&
– Justinas
Nov 20 '18 at 9:49
1
This really depends on how you're reading / displaying these results. It also seems very strange to have your request parameters HTML encoded. I suspect one or both of "you're viewing it incorrectly" and "something is manipulating the data in a bad way before you read it"
– Phil
Nov 21 '18 at 1:49
|
show 3 more comments
Could you post the actual parameters copied and pasted from your browser's address bar please?
– Scoots
Nov 20 '18 at 8:32
1
Have you tried comparing$this->request->get
and actual$_GET
? Maybe it's your parser that fails?
– Justinas
Nov 20 '18 at 9:04
@Justinas , $_GET["filters"] return the same. Cut result to Lemon... last part is missing
– S.M. Nat
Nov 20 '18 at 9:15
Check your php.ini and tell if value ofmax_value_length
does not exceeds your query string. Also note that query string starts with?
and not with&
– Justinas
Nov 20 '18 at 9:49
1
This really depends on how you're reading / displaying these results. It also seems very strange to have your request parameters HTML encoded. I suspect one or both of "you're viewing it incorrectly" and "something is manipulating the data in a bad way before you read it"
– Phil
Nov 21 '18 at 1:49
Could you post the actual parameters copied and pasted from your browser's address bar please?
– Scoots
Nov 20 '18 at 8:32
Could you post the actual parameters copied and pasted from your browser's address bar please?
– Scoots
Nov 20 '18 at 8:32
1
1
Have you tried comparing
$this->request->get
and actual $_GET
? Maybe it's your parser that fails?– Justinas
Nov 20 '18 at 9:04
Have you tried comparing
$this->request->get
and actual $_GET
? Maybe it's your parser that fails?– Justinas
Nov 20 '18 at 9:04
@Justinas , $_GET["filters"] return the same. Cut result to Lemon... last part is missing
– S.M. Nat
Nov 20 '18 at 9:15
@Justinas , $_GET["filters"] return the same. Cut result to Lemon... last part is missing
– S.M. Nat
Nov 20 '18 at 9:15
Check your php.ini and tell if value of
max_value_length
does not exceeds your query string. Also note that query string starts with ?
and not with &
– Justinas
Nov 20 '18 at 9:49
Check your php.ini and tell if value of
max_value_length
does not exceeds your query string. Also note that query string starts with ?
and not with &
– Justinas
Nov 20 '18 at 9:49
1
1
This really depends on how you're reading / displaying these results. It also seems very strange to have your request parameters HTML encoded. I suspect one or both of "you're viewing it incorrectly" and "something is manipulating the data in a bad way before you read it"
– Phil
Nov 21 '18 at 1:49
This really depends on how you're reading / displaying these results. It also seems very strange to have your request parameters HTML encoded. I suspect one or both of "you're viewing it incorrectly" and "something is manipulating the data in a bad way before you read it"
– Phil
Nov 21 '18 at 1:49
|
show 3 more comments
1 Answer
1
active
oldest
votes
Assuming you're creating the URL and query parameters in JS, you need to encode all parameters for use in a URL.
In your case...
const filters = {
"groupOp": "AND",
"rules": [
{
"field": "name",
"op": "cn",
"data": "Lemon & Eucalyptus"
}
]
}
const url = `http://blablabla?filters=${encodeURIComponent(JSON.stringify(filters))}`
document.write(`<pre>${url}</pre>`)
Notice the &
in "Lemon & Eucalyptus"
has become %26
An extra concern is that something is HTML-encoding your request parameters. You should not be doing that unless you are specifically displaying the information in an HTML document.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53388872%2fphp-cut-get-request-param%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Assuming you're creating the URL and query parameters in JS, you need to encode all parameters for use in a URL.
In your case...
const filters = {
"groupOp": "AND",
"rules": [
{
"field": "name",
"op": "cn",
"data": "Lemon & Eucalyptus"
}
]
}
const url = `http://blablabla?filters=${encodeURIComponent(JSON.stringify(filters))}`
document.write(`<pre>${url}</pre>`)
Notice the &
in "Lemon & Eucalyptus"
has become %26
An extra concern is that something is HTML-encoding your request parameters. You should not be doing that unless you are specifically displaying the information in an HTML document.
add a comment |
Assuming you're creating the URL and query parameters in JS, you need to encode all parameters for use in a URL.
In your case...
const filters = {
"groupOp": "AND",
"rules": [
{
"field": "name",
"op": "cn",
"data": "Lemon & Eucalyptus"
}
]
}
const url = `http://blablabla?filters=${encodeURIComponent(JSON.stringify(filters))}`
document.write(`<pre>${url}</pre>`)
Notice the &
in "Lemon & Eucalyptus"
has become %26
An extra concern is that something is HTML-encoding your request parameters. You should not be doing that unless you are specifically displaying the information in an HTML document.
add a comment |
Assuming you're creating the URL and query parameters in JS, you need to encode all parameters for use in a URL.
In your case...
const filters = {
"groupOp": "AND",
"rules": [
{
"field": "name",
"op": "cn",
"data": "Lemon & Eucalyptus"
}
]
}
const url = `http://blablabla?filters=${encodeURIComponent(JSON.stringify(filters))}`
document.write(`<pre>${url}</pre>`)
Notice the &
in "Lemon & Eucalyptus"
has become %26
An extra concern is that something is HTML-encoding your request parameters. You should not be doing that unless you are specifically displaying the information in an HTML document.
Assuming you're creating the URL and query parameters in JS, you need to encode all parameters for use in a URL.
In your case...
const filters = {
"groupOp": "AND",
"rules": [
{
"field": "name",
"op": "cn",
"data": "Lemon & Eucalyptus"
}
]
}
const url = `http://blablabla?filters=${encodeURIComponent(JSON.stringify(filters))}`
document.write(`<pre>${url}</pre>`)
Notice the &
in "Lemon & Eucalyptus"
has become %26
An extra concern is that something is HTML-encoding your request parameters. You should not be doing that unless you are specifically displaying the information in an HTML document.
const filters = {
"groupOp": "AND",
"rules": [
{
"field": "name",
"op": "cn",
"data": "Lemon & Eucalyptus"
}
]
}
const url = `http://blablabla?filters=${encodeURIComponent(JSON.stringify(filters))}`
document.write(`<pre>${url}</pre>`)
const filters = {
"groupOp": "AND",
"rules": [
{
"field": "name",
"op": "cn",
"data": "Lemon & Eucalyptus"
}
]
}
const url = `http://blablabla?filters=${encodeURIComponent(JSON.stringify(filters))}`
document.write(`<pre>${url}</pre>`)
answered Nov 21 '18 at 1:58
Phil
95.7k11136155
95.7k11136155
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53388872%2fphp-cut-get-request-param%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Could you post the actual parameters copied and pasted from your browser's address bar please?
– Scoots
Nov 20 '18 at 8:32
1
Have you tried comparing
$this->request->get
and actual$_GET
? Maybe it's your parser that fails?– Justinas
Nov 20 '18 at 9:04
@Justinas , $_GET["filters"] return the same. Cut result to Lemon... last part is missing
– S.M. Nat
Nov 20 '18 at 9:15
Check your php.ini and tell if value of
max_value_length
does not exceeds your query string. Also note that query string starts with?
and not with&
– Justinas
Nov 20 '18 at 9:49
1
This really depends on how you're reading / displaying these results. It also seems very strange to have your request parameters HTML encoded. I suspect one or both of "you're viewing it incorrectly" and "something is manipulating the data in a bad way before you read it"
– Phil
Nov 21 '18 at 1:49