KindEditor

1、進入官網

2、下載

  官網下載:http://kindeditor.net/down.php

3、文件夾說明

├── asp                          asp示例
├── asp.net                    asp.net示例
├── attached                  空文件夾,放置關聯文件attached
├── examples                 HTML示例
├── jsp                          java示例
├── kindeditor-all-min.js 全部JS(壓縮)
├── kindeditor-all.js        全部JS(未壓縮)
├── kindeditor-min.js      僅KindEditor JS(壓縮)
├── kindeditor.js            僅KindEditor JS(未壓縮)
├── lang                        支持語言
├── license.txt               License
├── php                        PHP示例
├── plugins                    KindEditor內部使用的插件
└── themes                   KindEditor主題

4、基本使用

<textarea name="content" id="content"></textarea><script src="/static/jquery-1.12.4.js"></script>
<script src="/static/plugins/kind-editor/kindeditor-all.js"></script>
<script>$(function () {initKindEditor();});function initKindEditor() {var kind = KindEditor.create('#content', {width: '100%',       // 文本框寬度(可以百分比或像素)height: '300px',     // 文本框高度(只能像素)minWidth: 200,       // 最小寬度(數字)minHeight: 400      // 最小高度(數字)});}
</script>

5、詳細參數

? ? ?http://kindeditor.net/docs/option.html

6、上傳文件示例

<!DOCTYPE html>
<html>
<head lang="en"><meta charset="UTF-8"><title></title>
</head>
<body><div><h1>文章內容</h1>{{ request.POST.content|safe }}
</div><form method="POST"><h1>請輸入內容:</h1>{% csrf_token %}<div style="width: 500px; margin: 0 auto;"><textarea name="content" id="content"></textarea></div><input type="submit" value="提交"/>
</form><script src="/static/jquery-1.12.4.js"></script>
<script src="/static/plugins/kind-editor/kindeditor-all.js"></script>
<script>$(function () {initKindEditor();});function initKindEditor() {var a = 'kind';var kind = KindEditor.create('#content', {width: '100%',       // 文本框寬度(可以百分比或像素)
            height: '300px',     // 文本框高度(只能像素)
            minWidth: 200,       // 最小寬度(數字)
            minHeight: 400,      // 最小高度(數字)
            uploadJson: '/kind/upload_img/',extraFileUploadParams: {'csrfmiddlewaretoken': '{{ csrf_token }}'},fileManagerJson: '/kind/file_manager/',allowPreviewEmoticons: true,allowImageUpload: true});}
</script>
</body>
</html>
HTML
import os
import json
import timefrom django.shortcuts import render
from django.shortcuts import HttpResponsedef index(request):"""首頁:param request::return:"""return render(request, 'index.html')def upload_img(request):"""文件上傳:param request::return:"""dic = {'error': 0,'url': '/static/imgs/20130809170025.png','message': '錯誤了...'}return HttpResponse(json.dumps(dic))def file_manager(request):"""文件管理:param request::return:"""dic = {}root_path = '/Users/wupeiqi/PycharmProjects/editors/static/'static_root_path = '/static/'request_path = request.GET.get('path')if request_path:abs_current_dir_path = os.path.join(root_path, request_path)move_up_dir_path = os.path.dirname(request_path.rstrip('/'))dic['moveup_dir_path'] = move_up_dir_path + '/' if move_up_dir_path else move_up_dir_pathelse:abs_current_dir_path = root_pathdic['moveup_dir_path'] = ''dic['current_dir_path'] = request_pathdic['current_url'] = os.path.join(static_root_path, request_path)file_list = []for item in os.listdir(abs_current_dir_path):abs_item_path = os.path.join(abs_current_dir_path, item)a, exts = os.path.splitext(item)is_dir = os.path.isdir(abs_item_path)if is_dir:temp = {'is_dir': True,'has_file': True,'filesize': 0,'dir_path': '','is_photo': False,'filetype': '','filename': item,'datetime': time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(os.path.getctime(abs_item_path)))}else:temp = {'is_dir': False,'has_file': False,'filesize': os.stat(abs_item_path).st_size,'dir_path': '','is_photo': True if exts.lower() in ['.jpg', '.png', '.jpeg'] else False,'filetype': exts.lower().strip('.'),'filename': item,'datetime': time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(os.path.getctime(abs_item_path)))}file_list.append(temp)dic['file_list'] = file_listreturn HttpResponse(json.dumps(dic))
views

7、XSS過濾特殊標簽

  處理依賴

pip3 install beautifulsoup4
from bs4 import BeautifulSoupclass XSSFilter(object):__instance = Nonedef __init__(self):# XSS白名單self.valid_tags = {"font": ['color', 'size', 'face', 'style'],'b': [],'div': [],"span": [],"table": ['border', 'cellspacing', 'cellpadding'],'th': ['colspan', 'rowspan'],'td': ['colspan', 'rowspan'],"a": ['href', 'target', 'name'],"img": ['src', 'alt', 'title'],'p': ['align'],"pre": ['class'],"hr": ['class'],'strong': []}@classmethoddef instance(cls):if not cls.__instance:obj = cls()cls.__instance = objreturn cls.__instancedef process(self, content):soup = BeautifulSoup(content, 'lxml')# 遍歷所有HTML標簽for tag in soup.find_all(recursive=True):# 判斷標簽名是否在白名單中if tag.name not in self.valid_tags:tag.hidden = Trueif tag.name not in ['html', 'body']:tag.hidden = Truetag.clear()continue# 當前標簽的所有屬性白名單attr_rules = self.valid_tags[tag.name]keys = list(tag.attrs.keys())for key in keys:if key not in attr_rules:del tag[key]return soup.renderContents()if __name__ == '__main__':html = """<p class="title"><b>The Dormouse's story</b></p><p class="story"><div name='root'>Once upon a time there were three little sisters; and their names were<a href="http://example.com/elsie" class="sister c1" style='color:red;background-color:green;' id="link1"><!-- Elsie --></a><a href="http://example.com/lacie" class="sister" id="link2">Lacie</a> and<a href="http://example.com/tillie" class="sister" id="link3">Tilffffffffffffflie</a>;and they lived at the bottom of a well.<script>alert(123)</script></div></p><p class="story">...</p>"""v = XSSFilter.instance().process(html)print(v)
XSS示例
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from bs4 import BeautifulSoupclass XSSFilter(object):__instance = Nonedef __init__(self):# XSS白名單self.valid_tags = {"font": ['color', 'size', 'face', 'style'],'b': [],'div': [],"span": [],"table": ['border', 'cellspacing', 'cellpadding'],'th': ['colspan', 'rowspan'],'td': ['colspan', 'rowspan'],"a": ['href', 'target', 'name'],"img": ['src', 'alt', 'title'],'p': ['align'],"pre": ['class'],"hr": ['class'],'strong': []}def __new__(cls, *args, **kwargs):"""單例模式:param cls::param args::param kwargs::return:"""if not cls.__instance:obj = object.__new__(cls, *args, **kwargs)cls.__instance = objreturn cls.__instancedef process(self, content):soup = BeautifulSoup(content, 'lxml')# 遍歷所有HTML標簽for tag in soup.find_all(recursive=True):# 判斷標簽名是否在白名單中if tag.name not in self.valid_tags:tag.hidden = Trueif tag.name not in ['html', 'body']:tag.hidden = Truetag.clear()continue# 當前標簽的所有屬性白名單attr_rules = self.valid_tags[tag.name]keys = list(tag.attrs.keys())for key in keys:if key not in attr_rules:del tag[key]return soup.renderContents()if __name__ == '__main__':html = """<p class="title"><b>The Dormouse's story</b></p><p class="story"><div name='root'>Once upon a time there were three little sisters; and their names were<a href="http://example.com/elsie" class="sister c1" style='color:red;background-color:green;' id="link1"><!-- Elsie --></a><a href="http://example.com/lacie" class="sister" id="link2">Lacie</a> and<a href="http://example.com/tillie" class="sister" id="link3">Tilffffffffffffflie</a>;and they lived at the bottom of a well.<script>alert(123)</script></div></p><p class="story">...</p>"""obj = XSSFilter()v = obj.process(html)print(v)
基于__new__實現單例模式示例

?

轉載于:https://www.cnblogs.com/wuyongqiang/p/7218650.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/252249.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/252249.shtml
英文地址,請注明出處:http://en.pswp.cn/news/252249.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

service mysqld start,Failed to start mysqld.service: Access denied

service mysqld start 然后報&#xff1a; AUTHENTICATING FOR org.freedesktop.systemd1.manage-units Authentication is required to start mysqld.service.Authenticating as: lll,,, (lll)Password: polkit-agent-helper-1: pam_authenticate failed: Authentication fa…

使用realsense t265測試svo2.0視覺里程計

畢業三年了&#xff0c;現在是第二份工作&#xff0c;第一份工作已經結束一年半了&#xff0c;這意味著&#xff0c;我有一年半的時間沒有搞視覺SLAM相關的東西了&#xff0c;雖然在第二份工作也是做視覺相關的&#xff0c;但是只是用到一些目標識別和跟蹤的知識&#xff0c;并…

JSP動作標識

jsp中include有兩種形式: include指令&#xff1a;<% include file""%> include動作&#xff1a;<jsp:include page"" /> 他們的區別&#xff1a; <% include file""%>又稱靜態包含&#xff0c;使用時要注意以下幾點&#xf…

面試必問之JVM原理

1&#xff1a;什么是JVM JVM是Java Virtual Machine&#xff08;Java虛擬機&#xff09;的縮寫&#xff0c;JVM是一種用于計算設備的規范&#xff0c;它是一個虛構出來的計算機&#xff0c;是通過在實際的計算機上仿真模擬各種計算機功能來實現的。Java虛擬機包括一套字節碼指令…

InfluxDB學習之InfluxDB的基本操作

InfluxDB提供類SQL語法&#xff0c;如果熟悉SQL的話會非常容易上手。本文就為大家介紹一下InfluxDB的基本操作。 InfluxDB提供類SQL語法&#xff0c;如果熟悉SQL的話會非常容易上手。 一、InfluxDB操作方式 InfluxDB提供三種操作方式&#xff1a; 1&#xff09;客戶端命令行方式…

運行svo 2.0的 vio時遇到opencv沖突的問題

當我運行如下指令時&#xff0c;遇到了如下問題 指令 cd svo_ws source ./devel/setup.bash roslaunch svo_ros euroc_vio_mono.launch rosbag play MH_01_easy.bag -s 50 運行時遇到的問題 OpenCV Error: Bad argument (Unknown interpolation method) in resize, file /b…

DOS Network一月項目月報

歡迎大家閱讀DOS Network第一期項目月報&#xff01;DOS為了跟大家更好的溝通和交流&#xff0c;將在每個月為大家跟進DOS Network項目進展月報。月報主要分為項目研發和社區及營銷兩個部分。 如果你是剛認識DOS Network預言機網絡的新朋友&#xff0c;歡迎查閱往期文章&#x…

lsof詳解

from:https://www.cnblogs.com/the-study-of-linux/p/5501593.html lsof (list open files)是一個列出當前系統打開文件的工具。在linux系統環境下&#xff0c;任何事物都可以以文件形式存在&#xff0c;通過文件不僅可以訪問常規的數據&#xff0c;還可以訪問網絡連接和硬件。…

Ubuntu18.04上下載安裝使用sogou輸入法

下載地址&#xff1a;搜狗輸入法Linux官網-首頁 安裝設置網址&#xff1a;搜狗輸入法Linux官網-安裝指導 這樣Ubuntu下工作就更加方便了。

正則

&#xff08;一&#xff09;字符類 [...]  方括號內的任意字符 [^...]   不在方括號內的任意字符 .    除換行符和其它Unicode行終止符之外的任意字符 \w   任何ASCII字符組成的單詞&#xff0c;等價于[a-zA-Z0-9] \W   任何非ASCII字符組成的單詞&#xff0c;等價…

使用Cloud Studio寫python

1、進入【騰訊云開發者平臺】 2、點擊【進入工作空間】 3、點擊【新建工作空間】 4、點擊【從模版創建】 選擇你需要的空間環境&#xff0c;就可以開始啦&#xff01;轉載于:https://juejin.im/post/5c75f79051882562962ef5d7

顯卡、顯卡驅動、顯存、GPU、CUDA、cuDNN

&#xfeff;&#xfeff;顯卡Video card&#xff0c;Graphics card&#xff0c;又叫顯示接口卡&#xff0c;是一個硬件概念&#xff08;相似的還有網卡&#xff09;&#xff0c;執行計算機到顯示設備的數模信號轉換任務&#xff0c;安裝在計算機的主板上&#xff0c;將計算機的…

ros rviz顯示rosbag中的圖像和imu數據

一、rosbag相關的指令 1. rostopic list //列舉出系統中正在發布的ros 話題 2. rosbag record -a //錄制系統中所有正在發布的ros 話題 3. rosbag record topic1 topic2 .... -o bagname.bag 4. rosbag play bagname.bag //播放bag文件 5. rosbag info bagname.bag //查看…

PX4的workqueue

Workqueue相當于是中斷子程序&#xff0c;然后在queue的cycle里面要注意&#xff0c;不能在cycle函數里面用printf打印&#xff0c;在cycle里面printf函數是打印不出來的。 也不能在cycle里面用while(1)&#xff0c;就是不能讓程序一直在queue里面執行&#xff0c;要想讓cycle執…

企業選擇 多云管理平臺 六大注意事項

企業選擇 多云管理平臺 六大注意事項 1、是否足夠簡單&#xff0c;學習曲線有多長 2、是否可實現自動化環境部署&#xff0c;日常運維作業等一系列操作&#xff1f; 3、是否可以管理全異構的云環境&#xff0c;支持主流公有云廠商的云資源&#xff1f; 4、是否能提供管理成本、…

面向接口編程

面向接口編程 一般在實現一個系統的時候,通常是將定義與實現合為一體,不加分離的&#xff0c;我認為最為理解的系統設計規范應該是所有的定義與實現分離&#xff0c;盡管這對于系統中某些復雜的情況有些繁煩。面向接口編程設計 使用面向接口編程思想將層與層之間通過接口依賴,下…

Java并發學習之一——線程的創建

與每個java語言中的元素一樣&#xff0c;線程是對象。在Java中&#xff0c;我們有兩種方式創建線程&#xff1a; 1、通過直接繼承thread類&#xff0c;然后覆蓋run方法。 2、構建一個實現Runnable接口的類&#xff0c;然后創建一個thread類對象并傳遞Runnable對象作為構造參數 …

day1||python

測試題&#xff1a; 0. Python 是什么類型的語言&#xff1f; Python是一種面向對象、解釋型、動態類型計算機程序設計語言解釋型&#xff1a;程序無需編譯成二進制代碼&#xff0c;而是在執行時對語句一條一條編譯動態類型&#xff1a;在程序執行過程中&#xff0c;可以改變變…

2.7萬字還原行業面貌,《2019 AI金融風控行業研究報告》正式上線!...

在金融科技領域&#xff0c;風險控制的重要性&#xff0c;從其關聯的金融業務和結合的技術維度可見一斑&#xff1a;風控涉及信用借貸、保險、支付、供應鏈金融等場景&#xff0c;并運用了包括生物特征識別、機器學習、自然語言處理、大數據、云計算等多項技術。 區別于美國有…

【原創】QT簡單計算器

代碼 //main.cpp#include "calculator_111.h" #include <QtWidgets/QApplication>int main(int argc, char *argv[]) { QApplication a(argc, argv); Calculator_111 w; w.show(); return a.exec(); /* //QT creator Calculator_111 win; win.show(); return…