I have Symfony 1.4 web-application.
Let's say my app is hosted on example.com and there is FAQ page there.
When I refer to my app like this: http://example.com/faq#faq1 everything works fine.
But when "#" is escaped: http://example.com/faq%23faq1
I see the following message in log produced by symfony:
[err] {sfError404Exception} Empty module and/or action after parsing the URL "/faq#faq1" (/).
So, it looks like Symfony recognizes there is "#" but fails to route it correctly.
routing.yml:
faq:
url: /faq
param: { module: static, action: faq }
requirements:
sf_method: [get]
How do I make Symfony to route URL with escaped characters correctly?
It's not a Symfony problem. It's not your problem. The problem come from people who escape #.
I took few examples:
OK - http://www.rue89.com/faq#5.7
NOK - http://www.rue89.com/faq%235.7
OK - http://www.openbsd.org/faq/faq1.html#WhatIs
NOK - http://www.openbsd.org/faq/faq1.html%23WhatIs
OK - http://www.copyright.gov/help/faq/faq-general.html#register
NOK - http://www.copyright.gov/help/faq/faq-general.html%23register
Etc ... etc ...
Related
I'm using Graylog to manage my server logs.
I would like to filter the apache logs access to keep the logs with a http response code 4** and 5**
So I would like to use a regex:
If I search /HTTP/ I have the corresponding logs like:
[...] "HEAD /register HTTP/1.1" 301 460 "-" [...]
But if I search /HTTP\//, I have no message. I also tried with /HTTP\\// but same result.
I tried with the regex /HTTP(?:.*?)"\s[4|5](?:\d{2})/ but no message found.
How to search a simple pattern like HTTP/ with a regex in Graylog ?
Thx
Why don't you use an extractor to map http-status-codes to fields.
Then you can easily filter and group your logs to find those with special codes.
Please see the following links
Extractors
How to use a JSON extractor
I am trying to consume the google text to speech api here : https://cloud.google.com/speech-to-text/docs/async-recognize#speech-async-recognize-gcs-protocol
and it has this url format below
https://google-speech-api-base-urlspeech:longrunningrecognize
What is this URL format with colon(:)in the end?
When I try to hit this URL, it gives me an error specifically while running test case on it .e. Invalid URI. Invalid Port?
But the official google documentation says this is a valid url? How to use this?
This format of URL is called gRPC Transcoding syntax. Your first URL is invlaid , because it's in the first path segment of a relative-path reference.
https://google-speech-api-base-urlspeech:longrunningrecognize
This url is invalid for usage, whereas the one below, https://speech.googleapis.com/v1/speech:longrunningrecognize was running fine.
Try changing your URL to something like
https://google-speech-api-base-url/speech:longrunningrecognize. It will work.
I looked at the documentation page you referenced and was unable to see/find a URL that looked like:
https://google-speech-api-base-urlspeech:longrunningrecognize
However, what I did find was a URL of the form:
https://speech.googleapis.com/v1/speech:longrunningrecognize
which looks perfectly valid.
The documentation for this REST request can be found here:
https://cloud.google.com/speech-to-text/docs/reference/rest/v1/speech/longrunningrecognize
Could you have made an error in your reading and comprehension?
Apparently the colon (:) is legal in the path part of a URL:
Are colons allowed in URLs?
I'm trying to do a redirect in Rails 4
get '/something)', to: redirect("/something", status: 301), format: false
This doesn't work because parentheses are used for optional parameters
The error is:
Racc::ParseError
parse error on value ")" (RPAREN)
I tried both URL encoding ) and escaping it \) and \\) but none of that worked.
From my searches it seems that nobody ran into it before. It's rather strange indeed, but someone added the parentheses by mistake when linking to my site and now I want to redirect visitors to the correct one instead of the 404.
You can do this,
constraints(path: /something\)/) do
get '/:path', to: redirect("/something", status: 301), format: false
end
But ideal way is to put this redirection in you web server (eg: nginx)
I wrote the following test tweet:
&“”‘’®©™¶•·§–—
Then fetched it using the 'user_timeline' api call. The following json was returned:
...
"text": "&“”‘’®©™¶•·§–—",
...
It seems strange the ampersand is the only escaped symbol.
Are there any other escaped symbols? I can't find a definitive list in the docs.
Alternatively, is it possible to specify if the api should return escaped/ unescaped characters?
Edit
Test tweet:
<>=+
Returns:
...
'text': '<>=+'
...
http://localhost/test/editformquestions.php#?formid=1
And
http://localhost/test/editformquestions.php?formid=1
I failed to retrieve $_GET['formid'] in the first one,why?
The content of test/editformquestions.php is simply:
<?php
echo $_GET['formid'];
?>
Characters after the hash # are to be used by the browser, they are not sent back to the server.
# is a hash character, not a GET variable.
You need to put the ? before any hashes, otherwise the $_GET array will not be populated.
# is used by the browser, and is never sent to the server. Everything after a # (regardless of what it is) is used by the browser to jump to a location on the page.
So:
http://localhost/test/editformquestions.php#?formid=1
Will be split as follows:
Server request to http://localhost/test/editformquestions.php
Browser then searches in page for:
<a name="?formid=1">named anchor tag</a>
What you should do is:
http://localhost/test/editformquestions.php?formid=1&othervar=2#anchorinpage
Or, if you need the # in a query-string parameter:
http://localhost/test/editformquestions.php?formid=1&othervar=textwith%23init
The # is fragment identifier for a URL: http://en.wikipedia.org/wiki/Fragment_identifier
To use it as part of an array variable you'll need to url encode it:
'#' becomes '%23' when url-encoded
In javascript you can accomplish url encoding with the encodeURI() function
A HTTP URL may contain these parts:
protocol: http://
domain: localhost
path: /test/editformquestions.php
query string: ?formid=1 - always starts with a ?
fragment: #something - always starts with a # - whatever comes after the # mark is NOT sent to the server.
What you have in your first example (http://localhost/test/editformquestions.php#?formid=1) is a fragment containing this: #?formid=1. It does not matter that there's a ? in the fragment; as soon as it's behind the #, it is not sent from the browser.
So, in essence, you are sending to the server only this: http://localhost/test/editformquestions.php - as you can see, there is no formid in that request.