Closed
Bug 561985
Opened 15 years ago
Closed 10 years ago
Use native JSON functions
Categories
(Tree Management Graveyard :: TBPL, defect, P5)
Tree Management Graveyard
TBPL
Tracking
(Not tracked)
RESOLVED
WONTFIX
People
(Reporter: Swatinem, Unassigned)
Details
Attachments
(2 files)
36.89 KB,
patch
|
mstange
:
review+
ehsan.akhgari
:
review-
|
Details | Diff | Splinter Review |
967 bytes,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
PHP had native json support since 5.2 (released in 2006), so use that.
Attachment #441733 -
Flags: review?(mstange)
Updated•15 years ago
|
Attachment #441733 -
Flags: review?(mstange) → review+
Reporter | ||
Comment 1•15 years ago
|
||
Comment on attachment 441733 [details] [diff] [review]
patch [pushed: comment 1]
http://hg.mozilla.org/users/mstange_themasta.com/tinderboxpushlog/rev/1dd3a48587eb
Attachment #441733 -
Attachment description: patch → patch [pushed: comment 1]
Reporter | ||
Updated•15 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Comment 2•15 years ago
|
||
There was a reason why I used Services_JSON instead of PHP's native json functions. Those functions are buggy as hell. For example, json_encode fails if there is a non-breaking space in the input.
This bug broke TinderboxPushlog Robot completely, and rendered it useless. I took the liberty of backing it out, and tested that revision locally to make sure that it works again.
http://hg.mozilla.org/users/mstange_themasta.com/tinderboxpushlog/rev/9f45e38f57c9
Markus, could you please deploy this changeset? Without it, tbplbot can't comment on any bug.
Resolution: FIXED → WONTFIX
Updated•15 years ago
|
Attachment #441733 -
Flags: review-
Reporter | ||
Comment 3•15 years ago
|
||
I took a quick look at PHPs bug tracker and there are indeed quite a few (closed) bugs about encoding errors.
Does the bug also occur with the latest stable release? If so, file a PHP bug.
$data = array(
"text" => $_GET["comment"]
);
That looks like the only interesting use of json_encode, which does depend on unfiltered user input. That input itself is generated from the tinderbox log, which itself claims to be utf8, but I wouldn't bet on that.
I'm perfectly fine with having this reverted, for now. But if the implementation is "buggy as hell" then get the PHP developers to fix it.
Comment 4•15 years ago
|
||
(In reply to comment #3)
> I took a quick look at PHPs bug tracker and there are indeed quite a few
> (closed) bugs about encoding errors.
>
> Does the bug also occur with the latest stable release? If so, file a PHP bug.
>
> $data = array(
> "text" => $_GET["comment"]
> );
>
> That looks like the only interesting use of json_encode, which does depend on
> unfiltered user input. That input itself is generated from the tinderbox log,
> which itself claims to be utf8, but I wouldn't bet on that.
>
> I'm perfectly fine with having this reverted, for now. But if the
> implementation is "buggy as hell" then get the PHP developers to fix it.
That code is indeed the one which fails. In this specific case, the failure is caused by json_encode failing to encode a non-breaking space.
I've filed this bug for the issue:
http://bugs.php.net/bug.php?id=51947
However, even with that fixed, I still won't feel comfortable with using json_encode, because I've had a lot of problems with it, and I don't think that the speed improvement is worth the risk.
Comment 5•15 years ago
|
||
(In reply to comment #2)
> This bug broke TinderboxPushlog Robot completely, and rendered it useless.
Huh? Didn't it still work like yesterday? Did I fail to deploy that file earlier?
Comment 6•15 years ago
|
||
Deployed the backout, in any case.
Reporter | ||
Comment 7•15 years ago
|
||
Thank you for filing a php bug. I've commented there on why I think it behaves correctly regarding invalid utf8 chars.
I would suggest fixing the test infrastructure to output correct utf8. Could you please file a bug? You know better than me which part of the tests output this.
Comment 8•15 years ago
|
||
(In reply to comment #7)
> Thank you for filing a php bug. I've commented there on why I think it behaves
> correctly regarding invalid utf8 chars.
>
> I would suggest fixing the test infrastructure to output correct utf8. Could
> you please file a bug? You know better than me which part of the tests output
> this.
That character is actually coming from the browser!
What happens is that we inject a span node with a data-signature attribute containing , and then we'll retrieve the value and post it to the server, escaped.
This test case also returns 160.
data:text/html;charset=utf-8,<p></p><script>var p=document.querySelector("p");p.innerHTML=' ';alert(p.textContent.charCodeAt(0))</script>
But this is the decoded value. I'm not sure what we're supposed to fix.
Comment 9•15 years ago
|
||
I filed bug 569154 about escape encoding nbsp to 0xA0.
Reporter | ||
Comment 10•15 years ago
|
||
Attachment #448352 -
Flags: review?
Reporter | ||
Updated•15 years ago
|
Attachment #448352 -
Flags: review? → review?(ehsan)
Reporter | ||
Updated•15 years ago
|
Status: RESOLVED → REOPENED
Resolution: WONTFIX → ---
Reporter | ||
Comment 11•15 years ago
|
||
Could you please test if this patch fixes the use of json_encode and reland the original patch?
Comment 12•15 years ago
|
||
Comment on attachment 448352 [details] [diff] [review]
use encodeURIComponent
Yes, it seems to work fine. Thanks!
Attachment #448352 -
Flags: review?(ehsan) → review+
Comment 13•15 years ago
|
||
So, things seemed to work fine, and I relanded this with the new patch combined.
http://hg.mozilla.org/users/mstange_themasta.com/tinderboxpushlog/rev/58be23887d91
Status: REOPENED → RESOLVED
Closed: 15 years ago → 15 years ago
Resolution: --- → FIXED
Comment 14•15 years ago
|
||
deployed
Comment 15•15 years ago
|
||
Oh, this broke the tbpl again.
{"error":1,"code":"Client","message":"Application failed during request deserialization: \nnot well-formed (invalid token) at line 3, column 64, byte 282 at /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/XML/Parser.pm line 187\n"}
http://hg.mozilla.org/users/mstange_themasta.com/tinderboxpushlog/rev/5ed9db12894b
Markus, could you please deploy this?
And Arpad, let's just not use native json functions here. It's really not worth it.
Resolution: FIXED → WONTFIX
Comment 16•15 years ago
|
||
(In reply to comment #15)
> Markus, could you please deploy this?
Done.
Comment 17•13 years ago
|
||
Going to reopen this so it appears on my searches & can be looked at in the future, on the off-chance newer php versions have fixed the issues with native json.
Assignee: arpad.borsos → nobody
Severity: normal → minor
Status: RESOLVED → REOPENED
OS: Linux → All
Priority: -- → P5
Hardware: x86 → All
Resolution: WONTFIX → ---
Comment 18•12 years ago
|
||
Is there any reason why we can't |json_encode(utf8_encode($foo))|, per the last comment in https://bugs.php.net/bug.php?id=51947 ?
Comment 19•12 years ago
|
||
(In reply to comment #18)
> Is there any reason why we can't |json_encode(utf8_encode($foo))|, per the last
> comment in https://bugs.php.net/bug.php?id=51947 ?
Hmm yeah that might work!
Assignee | ||
Updated•10 years ago
|
Product: Webtools → Tree Management
Comment 20•10 years ago
|
||
Wontfix since TBPL is being replaced by Treeherder.
Status: REOPENED → RESOLVED
Closed: 15 years ago → 10 years ago
Resolution: --- → WONTFIX
Assignee | ||
Updated•10 years ago
|
Product: Tree Management → Tree Management Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•