Is FILTER_SANITIZE_URL useless? [closed] - php

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
The documentation says:
Remove all characters except letters, digits and $-_.+!*'(),{}|\^~[]`<>#%";/?:#&=.
What's the point of using it if it allows quotes and stuff? I can just close the href attribute with " then put some JavaScript. Heck, I can put JavaScript even inside the URL.

It makes sure that the URL is valid. Protecting your presentation layer is up to you through use of well-known, battle-tested sanitization routines.

Related

How to sanitize textarea input for specific tags using php [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have reworded this question please disregard original comments
UPDATED QUESTION
If I want to remove one or more characters in a textarea using php, how would I do this?
MY SOLUTION FOR A SINGLE INSTANCE
str_replace("http://","",$_POST['Website']);
How would I remove/replace multiple items or lower upper instances, i.e. HTTP//: http//: HTTPS:// https//: hTTps//: ?
You either should have fixed dictionary for allowed tags and good PCRE knowledge (remember to use lazy quantifiers) or (and this I would advise) use markdown syntax (there are js editors) and compile it in php to valid html.

PHP Urls, what is the best way of making sure that they are properly formatted for hrefs [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have found a few ways of doing it, but what is the preferred method that doesn't require changing them before saving them into the database? I am using PHP (Laravel) and JS on the project.
You can use the url() helper.
url('user/profile') will append user/profile to your base url.
url('http://www.google.com') will not append, and will return http://www.google.com.

Find perpendicular segments at ends of segment [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Hello,
I'm making an application in which I have the points (p0,p1), and need to find the points for perpendicular segments at the end of (p0,p1)... namely, (A,B) and (C,D), which are of length $len.
There is a similar question to this one in this post, but unfortunately I am not sure about how to interpret the answer...
I'm using php for this project, but the solution can be in any language as I can translate it later.
(A-E)/(l/2) = (p1-F)/L
and so on...

Allow some html tags [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I need to allow certain html tags (br,p and strong) and I have encountered this code.
(strip_tags($this->parent->content[$i]['text']), $this->parent->config, 'portal_mode_grid_news_text_length', '…').'</p>';
All I need is to allow those tags I have stated previously, but I don't know how to do it.
If you look at the documentation for strip_tags, it shows that the second parameter is "allowed tags", so an example of how to allow br, p and strong is like so:
$string = "Hello<br>";
echo strip_tags($string, "<br><br/><p><strong>");
Adding br and br/ together allows both types of line break as opposed to just one.
(strip_tags($this->parent->content[$i]['text'], "<br><br/><p><strong>"), $this->parent->config, 'portal_mode_grid_news_text_length', '…').'</p>';

PHP, escape any characters [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Can I escape any character in string without using symbol "\"?
For example, programming language C# allows specify string, which does not have special characters:
#"c:\webserver\".Equals("c:\\webserver\\") // <== return true
Thanks for answers and sorry for my poor English!
to escape use addslashes(); and stripslashes() to remove added slashes
Do you want to automatically add slashes?
Then you can use built in php function:
addslashes();
http://php.net/manual/en/function.addslashes.php

Categories