Skip Menu |

This queue is for tickets about the JSON-XS CPAN distribution.

Report information
The Basics
Id: 97558
Status: resolved
Priority: 0/
Queue: JSON-XS

People
Owner: Nobody in particular
Requestors: lubo.rintel [...] gooddata.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: [PATCH] Tolerate literal ASCII TABs in strings in relaxed mode
[PATCH] Tolerate literal ASCII TABs in strings in relaxed mode Just encountered a JSON object that was messed up and there doesn't seem to be a better way to fix it.
Subject: 0001-Tolerate-literal-ASCII-TABs-in-strings-in-relaxed-mo.patch
From a6cf4c308da48bc11524c7517958af39654171da Mon Sep 17 00:00:00 2001 From: Lubomir Rintel <lkundrak@v3.sk> Date: Mon, 28 Jul 2014 14:25:08 +0200 Subject: [PATCH] Tolerate literal ASCII TABs in strings in relaxed mode Just encountered a JSON object that was messed up and there doesn't seem to be a better way to fix it. --- XS.pm | 10 ++++++++++ XS.xs | 4 +++- t/17_relaxed.t | 4 +++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/XS.pm b/XS.pm index d09d9e3..db4893f 100644 --- a/XS.pm +++ b/XS.pm @@ -406,6 +406,16 @@ character, after which more white-space and comments are allowed. # neither this one... ] +=item * literal ASCII TAB character + +Allow literal ASCII TAB in strings despite JSON mandates, that TAB +character is substituted for "\t" sequence. + + [ + "Hello\tWorld", + "Hello<TAB>World" <- literal <TAB> would not normally be allowed + ] + =back =item $json = $json->canonical ([$enable]) diff --git a/XS.xs b/XS.xs index 05d0c4a..e74aa65 100644 --- a/XS.xs +++ b/XS.xs @@ -1106,7 +1106,9 @@ decode_str (dec_t *dec) utf8 = 1; } - else + else if (dec->json.flags & F_RELAXED && ch == '\t') { + *cur++ = ch; + } else { --dec_cur; diff --git a/t/17_relaxed.t b/t/17_relaxed.t index 9dbcfb7..fc42465 100644 --- a/t/17_relaxed.t +++ b/t/17_relaxed.t @@ -1,4 +1,4 @@ -BEGIN { $| = 1; print "1..8\n"; } +BEGIN { $| = 1; print "1..9\n"; } use utf8; use JSON::XS; @@ -20,3 +20,5 @@ ok ('{"1":2}' eq encode_json $json->decode ('{"1":2,}')); ok (!eval { $json->decode ('{,}') }); ok ('[1,2]' eq encode_json $json->decode ("[1#,2\n ,2,# ] \n\t]")); + +ok ('["Hello\tWorld"]' eq encode_json $json->decode ("[\"Hello\tWorld\"]")); -- 1.8.3.1
Subject: Re: [rt.cpan.org #97558] [PATCH] Tolerate literal ASCII TABs in strings in relaxed mode
Date: Tue, 29 Jul 2014 00:01:20 +0200
To: Lubomir Rintel via RT <bug-JSON-XS [...] rt.cpan.org>
From: Marc Lehmann <schmorp [...] schmorp.de>
Hi! Please send your bug report it to the official contact/author address for the module in question (or send it to rt.cpan.org@schmorp.de, that's fine as well). What follows is the rationale for this request, you don't have to read it if you don't care. Why is this necessary? rt.cpan.org has many deficiencies which makes it tedious and hard to use, increasing the workload on the people who provide all the perl modules you probably appreciate (and that is really to be avoided - module authors should be able to invest all their time into improving their modules and not fighting with rt.cpan.org's bugs). Still, for some people, rt.cpan.org is useful to have, and some people even like it and really want to use it. That is fine, too. Unfortunately, the designers of rt.cpan.org didn't make their "service" optional - you can neither opt-in nor opt-out of rt.cpan.org as a module author. Just like a spammer, rt.cpan.org forces its "service" (whether wanted or unwanted) on everybody. Just like a spammer, they don't care for the people they actively hurt. Just like a spammer, they don't don't care to fix these issues and make their "service" ethically acceptable. You cannot even configure it to redirect tickets to somewhere else. Unfortunately, ignoring rt.cpan.org is not an option either: for people reporting possible bugs there is no indication that their report will be ignored, and for module authors it means they miss potentially vital bug reports such as yours (and of course it's a great impression if rt.cpan.org has lots of bug reports that are unanswered, making a module look unmaintained when in fact the opposite might be true). I am sorry that this wasted a bit of your time, but please understand that I am just as much a victim as you are - the problem is the unethical stance of the rt.cpan.org providers who force their "service" on everybody. Please redirect your bug report as stated in the beginning of this mail, and please consider petitioning the rt.cpan.org providers to stop their unethical behaviour and allow opt-in, opt-out, or some redirect option. One last issue: many people mail me that this can be "fixed" by including the bugtracker element in my module meta file. This is not true: 1. This field only affects search.cpan.org and maybe similar services. (Many people confuse rt.cpan.org with search.cpan.org for some reason). 2. It doesn't even work (there are still links to rt.cpan.org displayed). 3. Even if search.cpan.org does no longer display the link, it doesn't actually affect rt.cpan.org (and tests have shown that people go to rt.cpan.org regardless) Even *iff* rt.cpan.org would start listening on the bugtracker field, however, it's still wrong. I have a lot of modules, and each time a service like rt.cpan.org comes out, I would have to make dummy releases for all my modules. This not only creates a lot of extra work for me (I take releases very seriously) but also users, who would wonder why there is a new release. Thanks a lot, Marc Lehmann <rt.cpan.org@schmorp.de> Last updated: 2012-04-22