JSF external link - redirect

As this question, I'm trying to put a link to an external site.
The problem is that using:
Go to this site!
I think that this tag should not be controlled by JSF (not?) and generate a direct HTML, but anyway JSF modifies and produces a relative link (http://localhost/webapp/stackoverflow.com), as if it was an outcome. It also does even if the url is begins with www.. So, the question is:
I'm forced in JSF to put protocol, even with the <a> tag?

This is not specific to JSF. JSF is just a HTML code generator. You would have exactly the same problem when using plain HTML. All relative URLs in the HTML document are always relative to the base URL of the current request (as you see in browser address bar or have specified in HTML <base> tag).
You need to explicitly specify the scheme to make it an absolute URL instead.
Go to this site!

Related

How can I "drill down" into a website using Perl's WWW::Mechanize

I have used the WWW::Mechanize Perl module on a number of projects and it's helped me out a lot.
I am trying to use it on a different site and I can't "drill down" into the content of the site.
The site is https://customer.bookingbug.com/?client=hantsrecyclingcentres#/services
I have tried figure out what the URL would be to get content shown in the resulting HTML, such as bb.d570283b87c834518ba9.css, bb.d570283b87c834518ba9.js and version.js
I tried to copy the resulting HTML into this posting, but used all sorts of quote and code sample combinations and it wouldn't display properly.
Does anyone have any idea how I "navigate" this site using this Perl module please?
WWW::Mechanize is a web client with some HTML parsing capabilities. But as you clearly noticed, the information you want is not in the HTML document you requested. Either download the correct document (whatever that might be), or do what the browser does and execute the JavaScript. This would require a JavaScript engine. The simplest way to achieve that is to remote-control a web browser (e.g. using Selenium::Chrome).

TinyMCE converting ampersand in querystring to HTML entity

Edit: My assumptions about encoding were incorrect. I'm leaving the question as originally asked in case others come here with the same misunderstanding.
When I include a link in some text in the editor that includes a querystring, then view the source code, I can see that it's converted any & characters in the href to &, which breaks the links.
A link
becomes
A link
and if I change it back to just & in the source, click Ok on the view source dialog, then immediately view source again, it's already worked its charms and encoded the & once again.
Is there a way to cue the editor to go ahead and convert those outside tag attributes, but not mess with those in attributes?
Using an older version (4.0.12), but I see the behavior on the current live sample right on tinymce.com, so if it's a bug it looks like it hasn't been fixed. But I am wondering if it's just a setting I'm missing.
Relevant questions:
Do I encode ampersands in <a href...>?
Do ampersands still need to be encoded in URLs in HTML5?
The HTML spec actually states that ampersands in HTML attributes have to be encoded so TinyMCE is working 100% as it should. If your server side code is not handling that correctly that is an issue with the server side code.

Mixed Content: HTTPS site without specification

I am writing a program which will look for Mixed Content within a URL. The aim of this script is to extract all links in a page and convert these links to absolute links, and then to see if the content is mixed.
lets say we have this page https://www.example.com/xxx1/ i'm assuming that any reference to links within this page will ALWAYS connect through to the HTTPS site, unless the link is explicitly told otherwise?
E.g
/index.html = will be HTTPS
http://www.example.com/img/insecureImage.jpg = Will be HTTP - and therefore insecure?
True?
Thanks,
The situation with mixed content depends on whether the content is active or passive. If you have an HTTPS site, all active content will be blocked. If it is passive as in the case of the image you provided, it will be displayed by default, but users can choose in their browsers to block this too.
The example you give is of an image file, so that is passive mixed content and that would not be blocked by default, but could be by the user's settings as mentioned.
The following resources fit into that class:
img
audio
video
object
The guide I link to explains the active/passive mixed content quite well.
MDN Guide on Mixed Content
Yes, independent of mixed content or not, if you see a relative link it is intended to be appended to the origin domain, so in your example /index.html should be interpreted as (https://www.example.com/index.html).
If they are absolute links, determining if its mixed content is exactly like you suggest - check the uri scheme. To reference mixed content, even from the same server, you need to use absolute links, so it makes your task kind of easy.
You're on the right track.

text/html return from REST Service

I am returning text/html(MediaType.TEXT_HTML) from REST web service which I want to show in browser.
Return string from web Service Method=<html>
<body background=\"WEB-INF\\DSCN0651.JPG\">
<h1>Hello World!!!</h1>Visit W3Schools.com!
<audio autoplay><source src=\"WEB-INF\\Coolest_Sms_All_Time.mp3\" type="audio/mpeg"</audio>
</body></html>
The problem I am facing is the background = DSCN0651.JPG is not rendered in browser
The audio autoplay is not working as I am not able to hear sound in browser.
Though I am only able to see Hello World!!! and link www.w3schools.com! in browser after REST call.
I checked the deployment area both image and mp3 are deployed fine under WEB-INF folder
I am using IE/chrome browser to make a call to my WebService get method.
Please let me know what I am doing wrong.
To link images or audio (or whatever resource), you need to give a relative URL which the client browser can understand, by asking the server for that resource. If you have a webpage like the above at URL http://example.com/foo/bar, the browser will try to look up http://example.com/foo/bar/WEB-INF\DSCN0651.JPG, but that's an invalid URL. I suggest you check that by trying out the real URL yourself, and by seeing with Developer tools what the browser does with your page.
That URL is invalid at least because it uses a backward slash \ instead of a forward slash /. That's wrong in URLs.
Actually, what you're showing uses \" and \\, but those should appear only when you embed them as a string in source code, to represent respectively " and \. You might want to inspect the output to ensure that's correct.
Moreover, that URL contains WEB-INF. I assume you're using a Java application server. However, the content of the WEB-INF folder is handled specially by Java application servers — in fact, resources there are not accessible to the public! So you should probably move them elsewhere and update the path (the right place depends on what you're exactly doing). Probably moving them up, outside of WEB-INF, and updating the URLs already works.

Is it possible to make relative link to image in a markdown file in a gist?

I've got a gist which contains a markdown file and an image.
Is there a way to do a relative link to this image?
Something like ![My image](image.png) instead of ![My image](https://gist.github.com/user/605560c2961cb3025038/raw/b75d2...6e8/img.png)
Here is an example
As of now, relative image links are working for me, in both a repository and a wiki. I'm using syntax like this:
![Kiku](images/Kiku.jpg)
Here's an example:
https://github.com/mark-anders/relative-image-url
According to http://blog.rodneyrehm.de/archives/35-Including-Data-From-Github.html, the problem in using
https://gist.github.com/user/605560c2961cb3025038/raw/b75d2...6e8/img.png
is that the b75d2...6e8 part varies per file (a quick experimentation confirms it is the git blob id). However you can drop that part resulting in a URL pointing to the latest version:
https://gist.github.com/user/605560c2961cb3025038/raw/img.png
or to take a working example:
https://gist.githubusercontent.com/cben/46d9536baacb7c5d196c/raw/dodgetocat_v2.png
Relative path?
This also works as relative path raw/dodgetocat_v2.png!
However (as of late 2017) github can render the same gist from 2 URLs:
When viewed from https://gist.github.com/cben/46d9536baacb7c5d196c/ (with trailing slash), the relative path is appended, resolves to https://gist.github.com/cben/46d9536baacb7c5d196c/raw/dodgetocat_v2.png — works :-)
When viewed from https://gist.github.com/cben/46d9536baacb7c5d196c (no trailing slash), the relative path replaces the last part of the URL, resolves to https://gist.github.com/cben/raw/dodgetocat_v2.png — broken :-(
[UPDATED Dec 2017. Previous problems of raw files served as Content-Type: application/octet-stream and rewriting src attributes of images to camo.githubusercontent.com no longer happen, at least not for images from same gist.]
Alas, we can't just use the first URL and trust it to always work.
Currently neither form returns a redirect, nor serves a rel=canonical link. I wouldn't bet on Github to never change this!
All internal gist links (e.g. from user's page https://gist.github.com/cben/) omit the trailing slash :-(
Gists in Google search results omit the trailing slash :-(
(You could use relative path 46d9536baacb7c5d196c/raw/dodgetocat_v2.png that would only work without trailing slash, but that's also questionable idea, and less worth it — not really more flexible than full URL.)
Using a proxy?
Both can be worked around with a proxy fixing the Content-Type, e.g. Rawgit or Bl.ocks.org (not by Github, don't abuse them). Unfortunately Rawgit doesn't render Markdown, only serves files as-is, and Bl.ocks.org does render markdown but the URL structure is such that relative links won't work. This means you can either reference full external URL in Markdown, or relative in HTML :-(
See https://gist.github.com/cben/46d9536baacb7c5d196c/ forked off your gist,
and its index.html viewed via:
http://rawgit.com/cben/46d9536baacb7c5d196c/raw/index.html
http://rawgit.com/cben/46d9536baacb7c5d196c/raw/
http://bl.ocks.org/cben/raw/46d9536baacb7c5d196c
http://bl.ocks.org/cben/46d9536baacb7c5d196c
Yes, the relative link is working for me. I am using pancake.io to host my pages.
http://pancake.io/2c8aa8/topics/cpp/cpp.md
The images on that page are in the cpp folder.
The markdown code used for the first image is
![C++ Var Types](basic_cpp_var_types.png)
The markdown code (actually html) used for the second image is
<div style='float: center'>
<img style='width: 600px' src="prefixpostfixincrement.png"></img>
</div>
NOTE: I missed the gist part. Try the html way if gist doesn't support the markdown relative image path syntax.
tested just now...
i was unable to use relative urls on the github wiki.
i had to add the image to the wiki repo, then browser the repo and have github show it to me (so i could grab the url). then use the full url in the markdown. but luckily, the urls are simple to predict: https://github.com/*username*/*reponame*/wiki/*imagename.png*
i submitted this isse to the github support.
No, the relative URL to an image from markdown doesn’t work, so you’ll have to stick with the long, static URL:
https://gist.github.com/mattborn/c346c8689a5eaf86e823
However, relative URLs to some files work:
http://bl.ocks.org/mattborn/c346c8689a5eaf86e823
After scratching my head around this for good 15 minutes I realized:
Relative paths to images do work, but when you're writing a markdown file directly from the github web app, the images don't show up in preview. Once you commit the file the images are visible as expected