Pomax / node-flickrapi

A node.js (and client-library) implementation of the Flickr API with oauth API key authentication and API method proxying
177 stars 52 forks source link

Part of string can't setMeta() #87

Open teegh opened 8 years ago

teegh commented 8 years ago

Hi, I am very grateful to flickrapi. I have some questions. Part of string can't setMeta() . Is this the bug ?

I tried in the following environments . OSX 10.11 node.js v4.3 flickrapi@4.2 or flickrapi@0.3.32

var FlickrAPI  = require("flickrapi");
var flickrApiOptions = {
      api_key            : "xxx",
      secret             : "xxx",
      permissions        : "xxx",
      user_id            : "xxx",
      access_token       : "xxx",
      access_token_secret: "xxx"
        };

FlickrAPI.authenticate(flickrApiOptions, function(error, flickr) {

      if(!error){

        flickr.photos.setMeta(apiOptions, function(err, result) {

          /*

          I tried the following characters .
          ()=・"!#$%\*+/:;<>?@[]^_`{}|~。「」、',.&-

          */
          var apiOptions = {
            "photo_id" : "your-photo_id" ,
            "title" : "sample title ()=・\"!#$%\\*+/:;<>?@[]^_`{}|~。「」、',.&-"
          };

          if(err) {
                console.log(err);

                /*

                Error occurs. The following string can't input in flickrapi@4.2
                |^`

                Error occurs. The following string can't input in flickrapi@0.3.32
                ()!*'

                */

          }else{
                console.log("success");

          }
        });
      }
});

The following is the error message .

could not parse body as JSON: oauth_problem=signature_invalid&debug_sbs=GET%26https%3a%2f%2fapi%2eflickr%2ecom%2fservices%2frest%2f%26api_key%3dxxx%26format%3djson%26method%3dflickr%2ephotos%2esetMeta%26oauth_consumer_key%3dxxx%26oauth_nonce%3dxxx%26oauth_signature_method%3dHMAC%2dSHA1%26oauth_timestamp%3dxxx%26oauth_token%3dxxx%26photo_id%3dxxx%26title%3dsample%2520title

Maybe, This error might occur in other method.

Pomax commented 8 years ago

Hmm, it could be that |, ^ and ` don't get escaped properly.