nicolas2k / google-glass-api

Automatically exported from code.google.com/p/google-glass-api
1 stars 0 forks source link

Java SDK incorrectly encodes URL's inside JSON payload #368

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I’m about to send a timeline item to Glass, here is the relevant fragment of 
the item’s HTML I see (item.getHtml()):

      <div class="img" style="background-image: url(http://maps.googleapis.com/maps/api/staticmap?size=640x360&sensor=false&size=mid&markers=color:red%7C37.51746169725286,-122.01049988447537%7C37.513135118030334,-121.97585701813264%7C37.49128506565831,-121.92640297551293

I then call send:

                item = service.timeline().insert(item).execute();

and calling getHtml() again on the returned item, I now get:

      <div class="img" style="background-image:url(http://maps.googleapis.com/maps/api/staticmap?size=640x360&amp;sensor=false&amp;size=mid&amp;markers=color:red%7C37.51746169725286,-122.01049988447537%7C37.513135118030334,-121.97585701813264%7C37.49128506565831,-121.92640297551293)"></div>

Note that some parts of the URL have been URL encoded (“&” became 
“&amp;”) which causes Glass to not display it at all.

This prevents background images from being displayed.

I'm including below the full HTML, in case you need it.

<style>
  article.mosaic > .photo-overlay {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
  }
  article.mosaic > .img {
    float: left;
    background-repeat: no-repeat;
    background-position: 50% 50%;
    background-size: cover;
    width: 640px; height: 360px;
  }
  article.mosaic.mosaic2 > .img { width: 320px; height: 360px; }
  article.mosaic.mosaic3 > .img { width: 213.33px; height: 360px; }
  article.mosaic.mosaic4 > .img,
  article.mosaic.mosaic5 > .img { width: 320px; height: 180px; }
  article.mosaic.mosaic6 > .img,
  article.mosaic.mosaic7 > .img { width: 213.33px; height: 180px; }
  article.mosaic.mosaic8 > .img { width: 160px; height: 180px; }
</style>

<article class="mosaic mosaic1">
      <div class="img" style="background-image: url(http://maps.googleapis.com/maps/api/staticmap?size=640x360&sensor=false&size=mid&markers=color:red%7C37.51746169725286,-122.01049988447537%7C37.513135118030334,-121.97585701813264%7C37.49128506565831,-121.92640297551293
)"></div>
  <div class="photo-overlay"></div>

  <section>
    <ul class="text-small">
        <li style="border-bottom: 0px">Silman Sports And Recreation Center, Newark, CA</li>
        <li style="border-bottom: 0px">Fremont European, Fremont, CA</li>
        <li style="border-bottom: 0px">Stars Cleaners, Fremont, CA</li>
    </ul>
  </section>
  <footer>Foursquare mayor</footer>
</article>

Original issue reported on code.google.com by cbe...@gmail.com on 16 Jan 2014 at 10:03

GoogleCodeExporter commented 8 years ago
Hello,

Sorry for the late reply... Unfortunately, this seems more related to the Java 
client libraries which is maintained by another team.
The better way to get support on this issue is to file a bug on their issue 
tracker:
  https://code.google.com/p/google-api-java-client/issues/list

It seems that some escaping is taking place before the HTML is sent to the API.

Best,
Alain

Original comment by ala...@google.com on 22 Jan 2014 at 9:58