strip-tags

When strip_tags() Burns a Haystack

I've got a list of websites for each US Congress member that I'm programmatically crawling to scrape addresses. Many of the sites vary in their underlying markup, but this wasn't initially a problem until I started seeing that hundreds of sites were not giving the expected results for the script I had written. After taking some more tim...

How to run a data-modifying migration that uses strip_tags?

I'm adding a new column, summary, to an existing table. It will contain a plaintext snippet of the HTML from the column body. I want to create summaries for all existing emails when I run my migration. However, I can't figure out how to use strip_tags within my migration. Here's what I have so far: class AddSummaryToEmails < ActiveRec...

I'm learning PHP on my own and I've become aware of the strip_tags() function. Is this the only way to increase security?

I'm new to PHP and I'm following a tutorial here: Link It's pretty scary that a user can write php code in an input and basically screw your site, right? Well, now I'm a bit paranoid and I'd rather learn security best practices right off the bat than try to cram them in once I have some habits in me. Since I'm brand new to PHP (litera...

Using PHP substr() and strip_tags() while retaining formatting and without breaking HTML

I have various HTML strings to cut to 100 characters (of the stripped content, not the original) without stripping tags and without breaking HTML. Original HTML string (288 characters): $content = "<div>With a <span class='spanClass'>span over here</span> and a <div class='divClass'>nested div over <div class='nestedDivClass'>there</di...

PROBLEM: PHP strip_tags & multi-dimensional array form parameter

I'm having problems stripping the tags from the textual inputs retrieved from my form so as to do something with them in checkout.php. The input is stored in a multi-dimensional array. Here's my form: echo '<form name="choose" action="checkout.php" method="post" onsubmit="return validate_second_form(this);">'; echo '<input ...

PHP:HTML markup breking when taking first 200 chars

in my PHP web application,I have a dataentry form where users will enter data using a rich text editor (FCKEditor i m using) and will be saving the Markup from the editor to the DB table.In another page i have to display the first 200 chars of the content (with View more link to view the entire thing). So when i m taking first 200 chars,...

php form security

I was reading an article about form security becuase I have a form which a user can add messages. I read that it was best to use strip_tags(), htmlspecialchars() and nl2br() Somewhere else said to use html_entity_decode() I have this code in my page which takes the user input <?php $topicmessage = check_input($_POST['message']);...

PHP: How to mass replace $_POST[...] with strip_tags($_POST[...])

I'm currently recovering from a nasty XSS attack, and realized I never sanitized inputs on several of the forms on my site. I used Notepad++'s Find In Files feature to search for $_POST in all my PHP files, and got almost 5,000 results. Now, I really don't want to go and manually add strip_tags to every one of those results, but a repl...

How to strip tags in PHP using regex?

$string = 'text <span style="color:#f09;">text</span> <span class="data" data-url="http://www.google.com"&gt;google.com&lt;/span&gt; text <span class="data" data-url="http://www.yahoo.com"&gt;yahoo.com&lt;/span&gt; text.'; What I want to do is get the data-url from all spans with the class data. So, it should output: $string = 'text <...

Why doesn't strip_tags work in PHP?

I've got the following code: <?php echo strip_tags($firstArticle->introtext); ?> Where $firstArticle is a stdClass object: object(stdClass)[422] public 'link' => string '/maps101/index.php?option=com_content&view=article&id=57:greenlands-newest-iceberg&catid=11:geography-in-the-news' (length=125) public 'text' => string 'GREENLAN...

Strip Tags short div

Hello I have a lot of div tags, but I want to delete the div tag of characters in that little div tag.Number of string <10 ex $txt=<<<HTML <div class="abc"> 123ab</div> <div id="abc"> 123ab</div> <div class="abc"> 123abcdfdfsdfsdfdsfsdfsdfdsf</div> HTML; And return only dig(include long string) $txt=<<<HTML <div class="abc"> 1...

PHP strip tags also removing \n

I'm using strip_tags in PHP and after it has processed the string, the string now also contains no \n's.. Is this standard with strip_tags? ...