openhab / openhab1-addons

Add-ons for openHAB 1.x
Eclipse Public License 2.0
3.43k stars 1.69k forks source link

HTTP Binding : Issue when URL has spaces being 20% #4459

Closed TommySharpNZ closed 8 years ago

TommySharpNZ commented 8 years ago

It appears that if a URL has the special characters of 20% to represent a space then the HTTP Binding fails.

The use case is the Google Maps Distance Matrix API that allows you to query the estimated travel time between two addresses.

This is my Item Number TTW_Sonay "Sonay TTW [%s]" (GroupOutdoors) { http="<[https://maps.googleapis.com/maps/api/distancematrix/json?origins=OriginAddressHere&destinations=DestinationAddressHere&key=GoogleAPIKeyHere&language=en&departure_time=now:300000:JS(ttw_trafficTimesNumber.js)]"}

In my case the origin and distination addresses have spaces in them represented by 20%

This causes the error below.

2016-06-11 16:10:37.053 [ERROR] [.service.AbstractActiveService] - Error while executing background thread HTTP Refresh Service
java.util.UnknownFormatConversionException: Conversion = 'R'
at java.util.Formatter$FormatSpecifier.conversion(Unknown Source) ~[na:1.8.0_60]
at java.util.Formatter$FormatSpecifier.(Unknown Source) ~[na:1.8.0_60]
at java.util.Formatter.parse(Unknown Source) ~[na:1.8.0_60]
at java.util.Formatter.format(Unknown Source) ~[na:1.8.0_60]
at java.util.Formatter.format(Unknown Source) ~[na:1.8.0_60]
at java.lang.String.format(Unknown Source) ~[na:1.8.0_60]
at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:136) ~[na:na]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) ~[na:na]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) ~[na:na]

With assistance from watou it appears the issue is with this line? https://github.com/openhab/openhab/blob/master/bundles/binding/org.openhab.binding.http/src/main/java/org/openhab/binding/http/internal/HttpBinding.java#L144

9037568 commented 8 years ago

Should be fixed with #4460.