Request a resource with percent sign in path - apache

I need to request a file www.myserver.de/file%.pdf .
The file exists and requesting the renamed copy www.myserver.de/file.pdf works.
Is this expected behaviour?

% is the character for URL escape sequences. Try using %25 which decodes to a single % sign.

% has a special meaning in URLs, so you need to escape it in order to refer to files with %s in their names.
Try www.myserver.de/file%25.pdf instead.

Related

Delimit String off of Backslash SQL/SSIS

I'm trying to delimit a string based off of a backslash, I tried using the token function but then realized that the '\' character is an escape character. Is there any way to delimit the string off of a backslash?
This is what my token function currently looks like.
Token(#[User::DynamicFilename],"\", 7)
FIrst of all use double backslash \\ instead of one \, and you should use TOKEN with TOKEN Count functions in order to retrieve the file name:
TOKEN(#[User::DynamicFilename],"\\", TOKENCOUNT(#[User::DynamicFilename],"\\"))
So if you are looking to extract a filename from a full file path tokencount will detect the latest occurence of backslash. Example:
Consider that #[User::DynamicFilename] value is:
C:\My Files\Folder\file.txt
Since the TOKENCOUNT() will return 3 then the expression be will be
TOKEN(#[User::DynamicFilename],"\\",3)
And it will returns
File.txt
You need to put double the number of your backslashes.
In your example, it should be
Token(#[User::DynamicFilename],"\\", 7)
If you don't know how deep to go with token, i suggest the following to get your result.
right(#[User::DynamicFilename],findstring(reverse(#[User::DynamicFilename]),"\\")-1)

Renaming file via UNC path

I need to have my VB.NET program rename a file over the network.
Microsoft says that My.Computer.FileSystem.RenameFile does not work if the file path starts with two backslashes ("\\"). So, what other way is there of doing this? I just need to rename a file in the domain, for instance:
rename("\\domain\1\exemple.txt", "\\domain\1\exemple2.txt")
The second parameter for rename should be just the file name eg:
My.Computer.FileSystem.RenameFile("C:\Test.txt", "SecondTest.txt")
So try changing your code to this:
My.Computer.FileSystem.RenameFile(#"\\domain\1\exemple.txt", "exemple2.txt")
Also beware of escaping because \ is an escape character, so add a # before any string that contains \. This will cause it to ignore escaping and therefore will treat \ as a normal character

400 Bad Request when URL ends with %

All the URLs ending with % is giving following error
"Bad Request,Your browser sent a request that this server could not understand."
I have redesigned my website and earlier as per my google analytics URLs ending with % was running.
I want to mention that I tried using same old htaccess but was not able to fix it. Other important change which I made was in hosting where I have pointed my server into a sub folder or the root.
Please help me in fixing it
% is a reserved character and should not be used for anything except percent encoding.
If you really need to pass the character on your url, use %25
Try this: 400 Bad Request when URL ends with %
(move your mouse over it and look at the URL, it's the URL of this page with a % added to it!)
The problem is probably that the % is used as an escape character for special signs like spaces or non latin characters, and the browser expects a code behind it.

Whitespace encoding using stringByAddingPercentEscapesUsingEncoding

I am encoding white spaces in a string using
[#"iPhone Content.doc" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
in SKPSMTP message sending. But while receiving mail at attachments place I am getting the name iPhone%20Content.doc - instead of a space it shows %20. How can this be avoided / correctly encoded?
If you're doing stringByAddingPercentEscapesUsingEncoding then you're going to get percent signs in your result string... You can either use something different, or go back through and remove the percent signs later.
From the doc:
stringByAddingPercentEscapesUsingEncoding: Returns a representation of
the receiver using a given encoding to determine the percent escapes
necessary to convert the receiver into a legal URL string.
aka, "this method adds percent signs". If you want to reverse this process, use stringByReplacingPercentEscapesUsingEncoding
Just a side note, %20 is there because the hex representation of the space character is 20 and the % sign is an escape. You only need to do this for URLs, as they disallow the use of whitespace characters.
I got solution for my question. Actually am missed to set the "" to a string.
Of course the remote receiver can not accept the url with whitespace, so we must convert the URL address using the stringByAddingPercentEscapesUsingEncoding function.
This function replaces spaces in the URL expression with %20. It is especially useful when the URL contains non-ascii characters - you have use the function to percent-escape the URL so that the remote server can accept your request.

Configure apache to treat static resources with "?" character in filename

For various reasons, I have a bunch of static resources all with the following naming format:
xxxxx?yyyyy
where the x's are regular letter chars, and the y's numbers 0-9.
Apache is truncating the filename in the GET request at the "?" - as this is traditionally used to delinate query params - and thus reporting the followying error
file xxxx not found.
How can I get Apache to not think the y's are query args, and are actually part of the static file name?
Thanks very much for help,
Don
If you have control of how the URLs are being output, you can escape the '?' chars, This would be %3F instead of the '?'. The URL would therefore be
http://example.com/abcdef%3f99999