utf-8 url problem - url

I have a tomcat (7) server running, through which I try to access some public files by http. Some of the files on the filesystem have special characters in them. The ones without those special characters are found. The other ones give a 404. For example:
http://localhost:9090/processed/transcoded/Csángó_TÖMEGKERESZTELŐVEL_EGYBEKÖTÖTT_búcsú_Istensegítsfalvá20111053491309424029417_extracted.mp3"
From what I found out utf-8 in urls shouldn't be a problem. I've tried an url escape function on the filename, which resulted in:
http://localhost:9090/processed/transcoded/Cs%c3%a1ng%c3%b3_T%c3%96MEGKERESZTEL%c5%90VEL_EGYBEK%c3%96T%c3%96TT_b%c3%bacs%c3%ba_Istenseg%c3%adtsfalv%c3%a120111053491309424029417_extracted%2emp3
... but that didn't seem to solve anything either. What to try next? I have no clue what the problem is. Is it maybe related to a Tomcat settings?

Do you have URIEncoding="UTF-8" in your <Connector? If yes, here's what I would do:
create a test webapp which has a filter intercepting all calls to /processed/transcoded/*
place a breakpoint on that filter and see what you get. Does the file name make sense when decoded?
try to open a new java.io.File using this path (obviously prepending local location, e.g. /home/someuser/files/... and assuming the file is there).
I don't think tomcat does much more than what is listed above.
Another alternative would be to debug the Tomcat itself.

Related

typo3 website move to other domain - need help step by step

I just got a typo3 website and need to transfer to an other domain.
Is it enough to copy all the folders (except typo3temp?) to the new place?
First I just changed baseurl in ts but it didn't do anything..
Should I do anything with the database when it still on the same server?
In case your question is about "cloning" a complete TYPO3-system an rsync/copy of the whole folder (yes including typo3temp) is the best idea, as this works on all versions, everything else (like excluding typo3temp) depends a whole lot on your TYPO3 expertise to resolve. The database needs to be copied as well. If you need to change db-name or db-credentials on the new system you need to change them in
typo3conf/LocalConfiguration.php
As soon as you have done this Install Tool and Backend should work: At first try the Install Tool:
https://my.new.domain/typo3/install/
If that doesn't work your problem is with the webserver configuration or dns.
If that works (and the reports there show no errors), try the Backend:
https://my.new.domain/typo3/
In case your question is about which changes are necessary to your TYPO3-installation if domain changes and the web server itself is configured correctly, then there are probably two things you need to change, in order to make the frontend work (although both cases might be omitted, depending on your configuration):
sys_template record, if any of those use absRefPrefix or baseurl. If you have access to the MySQL-Database a
SELECT pid FROM sys_template WHERE config LIKE "%baseurl%" OR "%absRefPrefix";
might help finding the template, however these template configuration might also be stored in files (typically in fileadmin/templates/**)
sys_domain records, a MySQL
SELECT pid FROM sys_domain;
might uncover where those are stored
However these changes are only necessary to enable the frontend to work.
Add a domain record in the backend. And while you don't need the content of the typo3temp folder, make sure the folder actually exists.
When you go to the new domain name in your browser, what happens?
Do you get redirected to the old domain? If so, maybe there is an .htaccess redirect happening.
Do you get to the new domain, but if you click on a link end up on the old one?
Do you get an error? If so, what is the error?
Does something else happen?

Running graphgists locally fails

I'm interested in running a graphgist locally, for which there is a script here:
https://gist.github.com/jexp/70296ce410ff431ddbef
I was able to install the modules and run the two tasks but the last line of the script:
open http://localhost:8000/?http%3A%2F%2Flocalhost%3A8000%2Fgists%2Fmy-graph-use-case.adoc
produces an error: Not Found and trying to open the link in the comments:
http://localhost:8000/gists/my-graph-use-case.adoc
causes my browser to download a file for which I have no associated application. has anyone made this work and if so, how?
according to #MichaelHunger the issue is that the default behaviour in Python's SimpleHTTPServer is such that a trailing slash (/) gets added to the end of the url, messing up the request.
according to #PratikMandrekar, in the following article, the problem is that the url as it is in the script does not explicitly specify the file name, forcing the server to redirect to the default. see:
Why does SimpleHTTPServer redirect to ?querystring/ when I request ?querystring?
so after a little experimentation I found this to work:
http://localhost:8000/index.html?http%3A%2F%2Flocalhost%3A8000%2Fgists%2Fmy-graph-use-case.adoc
notice that the colons, slashes, etc. in the inner url must be encoded for this to work
There is a bug/default behavior in simple-http-client that makes it add slashes after query parameters which breaks our app in this case, I have to find a better replacement or fix it.
Perhaps I can also change the rabbithole project to server the graphgist files itself, so that it would be self-contained.

Path for ShellExecute of IExplorer.exe

I want to use ShellExecute iexplore.exe (with an html file name as a command line arg), even if iexplore isn't associated with html files.
Assuming the user hasn't uninstalled it, how safe is it to do so without supplying a path to the program. This works on my machine, i.e. the default Windows search path contains a path to iexplore.exe. Is it reasonable to expect this on all recent Windows (XP+) machines?
Is there a safer way to ShellExecute iexplore.exe?
(Delphi XE2)
(Although this question stands alone, I'll giving the user the option to run IE in the context of this SO question I asked at the same time: Detect Chrome as browser associated with html files in Windows)
'iexplore.exe' is not in the default search path. It's path is registered in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE key. If this key, for any reason, is missing or pointing to a wrong location, your approach won't work. I would think the probability of this happening would be quite low.
As one alternative, you can use Internet Explorer object. With a broken registry or similar, this may also fail, but it sounds like a more official way to me.
ie := CreateOleObject('InternetExplorer.Application');
ie.Visible := True;
ie.Navigate('http://example.com');
IE Object reference here.

How to access files in the Project Directory with Grails

I needed some templates to render some code for users to paste. I put these into
/project-dir/grails-app/resources/templates/quickInstallCode.html
Then I tried accessing them using their relative path (grails-app/resources/templates/quickInstallCode.html), and it worked great.
When we then deployed the application to a Tomcat Server, using a .war file, the paths began pointing to a wrong location.
ERROR call, Template file /var/lib/tomcat6/grails-app/resources/templates/quickInstallCode.html not found.
I assumed, that Grails, giving good defaults for everything would handle this mess for me, but it seems like it does not.
I also tried this call, and it seemed to work great, but when deployed, the BuildSettingsHolder did not contain build Settings, which resulted in a fatal error.
BuildSettingsHolder.settings.baseDir.toString()
http://grails.org/doc/latest/api/grails/util/BuildSettingsHolder.html
http://grails.org/doc/latest/api/grails/util/BuildSettings.html
I am pretty frustrated that I cannot get this easy task to work, but the reason that this is so complicated seems to be that all Files are encapsuled in a WAR and not unpacked on the Server.
So the Questions are:
Where in your Project would you put
Files like this?
How to get a
reliable and stable way to access
this files? I just need a stable path to a base directory, without having to hardcode something in the configuration ... This cannot be so hard.
I have 2 solution to propose for this situation:
Save the template in the database, in a setting table. This way guarantees that nothing can go wrong.
You can consider using the resource folder like Sachin & Nirmal has proposed. About security, I think you can configure SpringSecurity Plugin to protect the specific resources, so that it can only be accessed by the site user.
Take a look at this link and try to use the getResource that spring provides. Its way more flexible and configurable.
def filePath = "resources/file.txt"
def appHolder=ApplicationHolder.application.parentContext.getResource("classpath:$filePath")
By the way Conf is on the root of the classpath, you can stick the files in src/java or src/groovy.
I keep my static resources in web-app folder and access them like this
ApplicationHolder.application.parentContext.servletContext.getRealPath("quickInstallCode.html")
// quickInstallCode.html should be in web-app folder.

shellexecute fails to open http links for some users

Some users of an app of mine are reporting links dont open in the browser. I always launch them with shellexecute(0, 'open', 'http://...
what could I check for an incorrect(?) setting in the http link associations?
You're assuming that the browser registered the open verb. It may not have done so.
Just pass nil as the second parameter and omit the open, and let the OS determine what the default action is for the http:// protocol, and you should be fine.
Sounds like the default browser is not functioning quite right. I guess the first thing I would try is to have them enter an (any) url into start->run and see if that pops up.
You could also have them register what the settings on the URL below are:
http://russenreaktor.wordpress.com/2010/07/01/solved-fix-default-protocol-http-association-in-windows/
Or use the ftype utility on the cmdline:
C:\Users\marco>ftype http
http="C:\Program Files (x86)\Internet Explorer\iexplore.exe" -nohome
These operate on registry keys under HKEY_CLASSES_ROOT/protocolname with protocolname=http/ftp etc.
Making a simple app to dump these keys might help finding out what the pattern here is.
FYI, this failure can be dynamic -- i.e., the old MS PhotoEditor would block opening URLS using ShellExecute. (C.f., http://code.activestate.com/recipes/334665/ ). Fix is as noted in the recipe: write out an .HTML file and shellexecute that.

Resources