Tapestry "/" in parameters bug - url

If I add slash / to the parameter of a page, even in encoded form %2F I get an error.
Sample URL:
http://mywebsite.com/somepage?param=dfgdfg%2F
Error:
Input string 'dfgdfg/' is not valid; the character '/' at position 7 is not valid.
I am trying to pass whole URL as parameter (to later redirect user to that URL) so there are a lot of slashes in there.
Is this a bug? Is there any workaround?
I could theoretically replace all slashes with something else than %2F but that is something I would attempt after everything else fails...

As I've learned this happens on Jetty only, which I use for development...
This custom service override solved the problem:
http://tapestry.1045711.n5.nabble.com/Customising-T5-URL-Encoding-tp2412550p2412551.html
Looks very hacky but works :).

See the Web Services More example on the JumpStart page. Works for me on Jetty.
The JumpStart page has many "how-to-do-this-in-Tapestry" examples.

Related

URL Escaping with Unity (Firebase URL)

I am trying to download a image stored in the Firebase Storage, using Unity. I use Unity Firebase SKD (in Beta...). This is my code:
...
// Points to "1/preview.jpg"
Firebase.Storage.StorageReference img_ref = folder1_ref.Child("/preview.jpg");
// Fetch the download URL
img_ref.GetDownloadUrlAsync().ContinueWith(task => {
Debug.Log(task.Result.ToString());
});
The console output is:
https://firebasestorage.googleapis.com/v0/b/insidehome-29c9e.appspot.com/o/1/preview.jpg?alt=media&token=092a8de8-5047-4bce-b179-edd4101847a3
If I try to download the file using www or a browser, with this URL, I obtain an error. The good URL should be (copied by Firebase console):
https%3A%2F%2Ffirebasestorage.googleapis.com%2Fv0%2Fb%2Finsidehome-29c9e.appspot.com%2Fo%2F1%2Fpreview.jpg%3Falt%3Dmedia%26token%3D092a8de8-5047-4bce-b179-edd4101847a3
The difference is only in a single slash ("/") before the word "preview".
Is this strange? How could I fix it? I try Escape the URL but it change all the slash:
https%3A%2F%2Ffirebasestorage.googleapis.com%2Fv0%2Fb%2Finsidehome-29c9e.appspot.com%2Fo%2F1%2F99%2Fobama.jpg%3Falt%3Dmedia%26token%3D8a33f998-e271-4d7e-8848-356a332b7750
And It does't work. I need to change only the parameters (right) slash
Hi Firebase engineer here. This is a bug and I'm sorry you encountered this. There should be no slash after "/o/". The 2 slashes surrounding the letter "o" are valid, but every forward slash after that should be displayed as %2F.
This is not a general escaping issue as you should not re-escape the entire URL. This is a side effect of a related mono issue in unity where the Uri class incorrectly decodes %2F into a slash when it shouldn't.
You can work around this by simply replacing slashes after "/o/" with %2F. However, you should know about a corresponding issue with UnityWebRequest:
https://issuetracker.unity3d.com/issues/unitywebrequest-dot-url-unescapes-escaped-symbol
where Unity's libraries are also being affected by this bug (so it may break even if you fix the string and pass it back to unity). It looks like that issue was fixed in 5.5.1 (and I've verified it in 5.6 beta).
On the firebase side, we will change our code to account for this issue in mono so it returns the correct url. Until we get this fix out, I suggest using the workaround of replacing slashes or simply use Firebase itself to download the file.
You can use Unity's WWW.EscapeURL to escape url.
string escapedUrl = WWW.EscapeURL("http://www.someurl");

What does "URL=" in a URL Mean?

May be a dumb question, but it's been bugging me recently. I see "URL=" inside alot of URL's, such as this one:
http://www.tierraantigua.com/search-2?url=http%3A%2F%2Flink.flexmls.com%2Fwws30ham
What exactly is this used to do? Is it part of the iFrame functionality? I know the last part of the URL (after the URL=) is the part being displayed in the iFrame, but I'm unsure of why it is included in the primary URL as well.
Thanks!
The url you see here is just a standard query parameter wit the name url and the encoded value http%3A%2F%2Flink.flexmls.com%2Fwws30ham which decodes to http://link.flexmls.com/Fwws30ham. Most of the times it is used for determining redirection or source information by the application you are using. It is entirely domain-specific and can have any meaning the website developer would like to use.
PHP GET
Description ΒΆ
An associative array of variables passed to the current script via the URL parameters.
$url = $_GET['url'];
echo $url; // http%3A%2F%2Flink.flexmls.com%2Fwws30ham

FormIt - redirect hook issue

ISSUE: I'm using FormIt and the redirect hook is not working for me.
It is redirecting to http://www.example.comPageName.html instead of http://www.example.com/PageName.html. It is not placing the forward slash after the page name.
Has anyone seen this issue before?
Here is my FormIt snippet.
[[!FormIt? &hooks=`email,redirect` &emailTpl=`MyEmailChunk` &emailTo=`mypersonalemail#email.com` &emailSubject=`Contact Us form submission` &redirectTo=`35` &emailFrom=`info#domainnamme.com`]]
Yes, the MyEmailChunk exists.
The email addresses are dummy values
The resource with id 35 is in the same context and is published and is hidden from the menus.
I'm using friendly urls.
If I try another resource it works.
URL generated in the following code
$url = $this->modx->makeUrl($this->formit->config['redirectTo'],$contextKey,$redirectParams,'full');
'full' means URL is absolute, prepended with site_url from config ( http://rtfm.modx.com/display/revolution20/modX.makeUrl ). Please check your site_url variable in /core/config/config.inc.php
Actually the site_url variable needs to be checked in the System Settings.
Make sure you have a trailing slash.

How do SO URLs self correct themselves if they are mistyped?

If an extra character (like a period, comma or a bracket or even alphabets) gets accidentally added to URL on the stackoverflow.com domain, a 404 error page is not thrown. Instead, URLs self correct themselves & the user is led to the relevant webpage.
For instance, the extra 4 letters I added to the end of a valid SO URL to demonstrate this would be automatically removed when you access the below URL -
https://stackoverflow.com/questions/194812/list-of-freely-available-programming-booksasdf
I guess this has something to do with ASP.NET MVC Routing. How is this feature implemented?
Well, this is quite simple to explain I guess, even without knowing the code behind it:
The text is just candy for search engines and people reading the URL:
This URL will work as well, with the complete text removed!
The only part really important is the question ID that's also embedded in the "path".
This is because EVERYTHING after http://stackoverflow.com/questions/194812 is ignored. It is just there to make the link, if posted somewhere, if more speaking.
Internally the URL is mapped to a handler, e.g., by a rewrite, that transforms into something like: http://stackoverflow.com/questions.php?id=194812 (just an example, don't know the correct internal URL)
This also makes the URL search engine friendly, besides being more readable to humans.

Problem with encode slash in url

I have problem with encode slash in url.
Problem:
from request in GSP page:
Gallery
I got:
http://foo.cz/myapp/page/show?url=home%2Fgallery
in address row in Internet browser.
Problem is with encode character from "/" to "%2F".
Explanation:
this is link in my gsp file:
Gallery
after click request goes to controller:
def show ={
def page = Page.findByUrl( params.url ) //it works
}
then I got gsp page in my Internet browser. All work fine, I got required page, but in adress row in Internet browser I saw:
http://foo.cz/myapp/page/show?url=home%2Fgallery
There is not character "/", but encode "%2F"
Motivation
I want to set the url in UrlMapping.groovy to:
"/${url}" (controller:"page", action:"show")
and get:
http://foo.cz/myapp/home/gallery/
but there are problem with encode character "/".
Finish
Can you help me please?
Thanks a lot Tom
you need to decode the Url in grails
http://www.grails.org/Dynamic+Encoding+Methods
it is not difficult replace "%2F" to "/", but then, there are problem with url mapping.
Transformation is in Grails tag CreateLink.
See source. There are involve String method encodeAsURL() as Aaron Saunders told my above.
For example, You can only write your own tag and use String method replaceAll("%F2", "/") and it work.
I got desired url in address row in Internet browser:
http://foo.cz/myapp/page/show?url=home/gallery
and I replaced to in MappingURL.groovy to:
http://foo.cz/myapp/home/gallery
Hmm, I have to use wildcart and other dirty code in controller.
It is not nice code.
Now I know, that is not good idea use slash(/) in params as Olexandr told my above.
It is work fine when You use for example "-" or other save URL character as param delimiter.
Thanks a lot all gurus.
Tom

Resources