[SOLVED] Add URL link to sitemap

Hello there
My question is: Is there a way to add a clickable link to another webpage on a sitemap?

My first example would be a link to say WUnderground weather on my weather page in my sitemap. You know in case i want more information.
Another would be to have a shortcut to another sitemap that is more specialized for a scenario. (like the master sitemap have a link for other niche sitemaps)

Yet another would be to have a shortcut to my 3dprinter control webpage in my sitemap.

This would be nice to have. Is it possible?

Solution:
For any URL

String WUnderground_URL "<a href='https://www.wunderground.com'>Weather Underground</a>"
```
For local sitemaps 
````java 
String LINK_THERMOSTAT "<a href='/openhab.app?sitemap=thermostat'>Thermostat control</a>"
```

I think if you create an HTML file with that link, put it in your webapps folder, then use a webview on your sitemap that should work.

There is no way to put one on your sitemap directly though.

1 Like

Not true! Well partially not true. This works for the classic UI.

String LINK_THERMOSTAT "<a href='/openhab.app?sitemap=thermostat'>Thermostat control</a>"

and


Frame label="By Location" {
(...)
        Text item=LINK_THERMOSTAT
    }
2 Likes

Well shoot. The last time I tried that I couldn’t get a thing to work. Is this relatively new or did I just muck it up the last time I tired (probably the latter)?

I notice this info is missing from the sitemap wiki page.

Heh, really don’t have enough info to say either way! :wink: I will say I’m still running 1.8.1, for various and sundry reasons.

Yeah, hmmm
 not really sure how to add it in there to be honest. Right now I’m not coming up with anything that doesn’t look ham handed and out of place.

Meh, let it be ham handed. So long as it gets capture somewhere people can find it and we can focus on making it look “good” in the OH 2 docs.

Thanks this works for sitemaps :slight_smile: Does this work for any http://www.cats.com URL? or only sitemaps internally.

edit: so that was just some random url I made up
 who knew it actually existed lol
edit2: If it does work for any URL, what’s the syntax after href= ?

Scratch that. Figured it out. Thanks guys :slight_smile:

For any URL

String WUnderground_URL "<a href='https://www.wunderground.com'>Weather Underground</a>"
```
For local sitemaps 
````java 
String LINK_THERMOSTAT "<a href='/openhab.app?sitemap=thermostat'>Thermostat control</a>"
```
1 Like

While this may work to provide the functionality you’re after, I can’t help but see the fact you can inject html like that as a security vulnerability.

1 Like

Do you mean as a user implementing it, or as the platform allowing linking to internal sitemaps?

Also when I add that code to my sitemap, I’m getting this visual bug. The next two entries are covered by the same ‘url link’ as the text item. Rendering the lightswitch unaccessible

Frame label="Weather" {
		Text item=Condition_Id icon="yahoo_weather" {
			... }
		Text item=WUnderground_URL
	} // weather frame
Frame label="Light"  {
		//Switch item=Light_Bedroom label="Bedroom light" //mappings=[ON="On", OFF="Off"]
		Switch item=MS_BR_Light icon="light"
		Switch item=MS_Motion	icon="motion"
               Text icon="settings" {
                     ... 
               }
               ...
}

Scratch that.
After reviewing basic HTML code http://www.w3schools.com/tags/att_a_href.asp, I found my problem. I left out the </a> at the end.

Second chance at google-fu led me to the sitemap samples where it fits much more cleanly. :wink:

Is it, though? More to the point, in order to exploit this wouldn’t you have to have write access to both $openhab/configurations/items and $openhab/configurations/sitemaps ? My thinking is that if you have write access to those directories, haven’t you already lost the game?

No, they only need to be able to update your item that contains the address.


which would require write access to $openhab/configurations/items/ . (I don’t see the distinction you’re trying to make.)

1 Like

There’s more than one way to update an item’s value. See REST API etc.

Ha, oh yeah! Well hey, that’s why I was asking the question! :slight_smile:

@danielwalters86is correct. This could be exploited by an attacker who could modify the value of your URL Item, e.g through the REST API.

I think the likelihood of such an attack is low and assuming you have security enabled you already have bigger problems if an attacker can get to your api.

But given that the site map renders href, it does seem likely that one could exploit this for a cross site scripting attack, phishing, and drive by malicious software infection.

It is only by accident that you can embed working HTML tags in item labels, and it only works on browser clients. Ideally, there would be either a new widget type or hint so that URLs would be formally supported.

1 Like