Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix paste preprocessing regexAttr #310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
Loading
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ var InputfieldTinyMCE = {
var t = InputfieldTinyMCE;
var allow = ',' + ProcessWire.config.InputfieldTinyMCE.pasteFilter + ',';
var regexTag = /<([a-z0-9:!\[\]]+)([^>]*)>/gi;
var regexAttr = /([-_a-z0-9]+)=["']([^"']*)["']/gi;
var regexAttr = /([-_a-z0-9]+)(?:\s*=\s*(?:(["'])(.*?)\2|(\S+)))?/gi;
var html = args.content;
var matchTag, matchAttr;
var removals = [];
Expand Down Expand Up @@ -676,13 +676,13 @@ var InputfieldTinyMCE = {
var attrRemoves = [];

while((matchAttr = regexAttr.exec(tagAttrs)) !== null) {
var attrStr = matchAttr[0]; // i.e. alt="hello"
var attrStr = matchAttr[0]; // i.e. alt="hello", alt = 'hello', height=20, hidden
var attrName = matchAttr[1]; // i.e. alt
var attrVal = matchAttr[2]; // i.e. hello
var attrVal = matchAttr[3] || matchAttr[4] || null; // i.e. hello, hello, 20, null

if(allow.indexOf(',' + tagName + '[' + attrName + ']') > -1) {
// matches whitelist of tag with allowed attribute
} else if(allow.indexOf(',' + tagName + '[' + attrName + '=' + attrVal + ']') > -1) {
} else if(attrVal !== null && allow.indexOf(',' + tagName + '[' + attrName + '=' + attrVal + ']') > -1) {
// matches whitelist of tag with allowed attribute having allowed value
} else {
// attributes do not match whitelist
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.