Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div>
- ...Some code here...
- </div>
- <?php
- /**
- * Ok, glad you are here
- * first we get a config instance, and set the settings
- * $config = HTMLPurifier_Config::createDefault();
- * $config->set('Core.Encoding', $this->config->get('purifier.encoding'));
- * $config->set('Cache.SerializerPath', $this->config->get('purifier.cachePath'));
- * if ( ! $this->config->get('purifier.finalize')) {
- * $config->autoFinalize = false;
- * }
- * $config->loadArray($this->getConfig());
- *
- * You must NOT delete the default settings
- * anything in settings should be compacted with params that needed to instance HTMLPurifier_Config.
- *
- * @link http://htmlpurifier.org/live/configdoc/plain.html
- */
- return [
- 'encoding' => 'UTF-8',
- 'finalize' => true,
- 'cachePath' => storage_path('app/purifier'),
- 'cacheFileMode' => 0755,
- 'settings' => [
- 'default' => [
- 'HTML.Doctype' => 'HTML 4.01 Transitional',
- 'HTML.Allowed' => 'blockquote,h1,h2,h3,h4,h5,h6,pre,code,div[class],b,strong,i,em,a[href|title],ul,ol,li,p[style],br,span[style],img[width|height|alt|src]',
- 'CSS.AllowedProperties' => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align',
- 'AutoFormat.AutoParagraph' => false,
- 'AutoFormat.RemoveEmpty' => true,
- ],
- 'test' => [
- 'Attr.EnableID' => true
- ],
- "youtube" => [
- "HTML.SafeIframe" => 'true',
- "URI.SafeIframeRegexp" => "%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/)%",
- ],
- ],
- ];
- public function store(Request $request)
- {
- //Validate the data
- $this->validate($request, array(
- 'title' => 'required|max:255',
- 'slug' => 'required|alpha_dash|min:5|max:255|unique:posts,slug',
- 'category_id' =>'required|integer',
- 'body' => 'required'
- ));
- //Store in the database
- $post = new Post;
- $post->title = $request->title;
- $post->slug = $request->slug;
- $post->category_id = $request->category_id;
- $post->body = Purifier::clean($request->body, "youtube");
- $post->save();
- $post->tags()->sync($request->tags, false);
- Session::flash('success', 'AWESOMESAUCE! Your post was saved successfully!');
- //redirect to another page
- return redirect()->route('posts.show', $post->id);
- }
- <?php
- $str = "This is some <b>bold</b> text.";
- echo htmlspecialchars($str);
- ?>
- This is some <b>bold</b> text.
- pre[class],code
- $post->body = clean($request->body, "youtube");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement