[ckan-dev] problem with "&"

David Read david.read at okfn.org
Tue Sep 6 16:47:40 UTC 2011


On 6 September 2011 15:16, David Read <david.read at okfn.org> wrote:
> Hi Florian,
>
> On 6 September 2011 11:49, Florian Marienfeld
> <florian.marienfeld at fokus.fraunhofer.de> wrote:
>> Hi,
>>
>> I am having trouble with the characters "=&;".
>> if they occur e.g. in the title of a package, I get a 400-Bad-Request
>> when I try to register a package by POSTing to ckan/rest/api/package
>>
>> However, when I PUT the same package as an edit to
>> ckan/rest/api/package/existing_package, it works and the title shows
>> correctly on the front end and API.
>>
>> Am I doing something wrong, or is this a bug?
>
> Florian,
> I've reproduced this and it shows the problem is with the JSON decoding:
>
> (pyenv-ckan)dread at dread-laptop:~/hgroot/ckan$ curl -i
> http://localhost:5000/api/rest/package -d '{"name": "test3", "title":
> "Test &"}' -H "Authorization:tester"
> HTTP/1.0 400 Bad Request
> Server: PasteWSGIServer/0.5 Python/2.6.5
> Date: Tue, 06 Sep 2011 14:09:31 GMT
> Pragma: no-cache
> Cache-Control: no-cache
> Content-Type: application/json;charset=utf-8
> Content-Length: 87
>
> "Bad request - JSON Error: Unterminated string starting at: line 1
> column 27 (char 27)"
>
> It looks like a bug - many thanks for raising it. I've filled in this
> ticket: http://trac.ckan.org/ticket/1312
> I should be able to get a fix out today or tomorrow. Cheers,

Florian,

I think this is to do with the Content-Type header from your client.
This defaults to URL Encoding, so either use percent notation for
these special characters, or even more simply, specify JSON encoding.
See my full explanation on the ticket comments:
http://trac.ckan.org/ticket/1312
(BTW I could not see any difference between package creation and editing.)

David

>
> David
>
>>
>> Thanks in advance, best regards,
>>
>> FLO
>>
>> --
>> Florian Marienfeld
>> Dipl.-Ing. Tech.-Inf.
>>
>> Fraunhofer FOKUS
>> - CC Motion -
>> Kaiserin-Augusta-Allee 31
>> 10589 Berlin
>> +49 30 3463 7127
>>
>>
>> _______________________________________________
>> ckan-dev mailing list
>> ckan-dev at lists.okfn.org
>> http://lists.okfn.org/mailman/listinfo/ckan-dev
>>
>




More information about the ckan-dev mailing list