Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
b2fbf537
Commit
b2fbf537
authored
Mar 29, 2012
by
Bridger Maxwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly escaping the schematic html attributes.
parent
f62a4396
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
5 deletions
+15
-5
djangoapps/simplewiki/mdx_circuit.py
+3
-1
static/js/CodeMirror/mitx_markdown.js
+12
-4
No files found.
djangoapps/simplewiki/mdx_circuit.py
View file @
b2fbf537
...
@@ -10,6 +10,7 @@ import re
...
@@ -10,6 +10,7 @@ import re
import
simplewiki.settings
as
settings
import
simplewiki.settings
as
settings
from
django.utils.html
import
escape
from
mitxmako.shortcuts
import
render_to_response
,
render_to_string
from
mitxmako.shortcuts
import
render_to_response
,
render_to_string
...
@@ -56,8 +57,9 @@ class CircuitPreprocessor(markdown.preprocessors.Preprocessor):
...
@@ -56,8 +57,9 @@ class CircuitPreprocessor(markdown.preprocessors.Preprocessor):
class
CircuitLink
(
markdown
.
inlinepatterns
.
Pattern
):
class
CircuitLink
(
markdown
.
inlinepatterns
.
Pattern
):
def
handleMatch
(
self
,
m
):
def
handleMatch
(
self
,
m
):
data
=
m
.
group
(
'data'
)
data
=
m
.
group
(
'data'
)
data
=
escape
(
data
)
##TODO: We need to html escape the data
##TODO: We need to html escape the data
return
etree
.
fromstring
(
"<
input type='hidden' parts='' value='"
+
data
+
"' analyses='' class='schematic ctrls' width='150' height='150'/
>"
)
return
etree
.
fromstring
(
"<
div align='center'><input type='hidden' parts='' value='"
+
data
+
"' analyses='' class='schematic ctrls' width='150' height='150'/></div
>"
)
def
makeExtension
(
configs
=
None
)
:
def
makeExtension
(
configs
=
None
)
:
...
...
static/js/CodeMirror/mitx_markdown.js
View file @
b2fbf537
...
@@ -58,20 +58,28 @@ CodeMirror.defineMode("mitx_markdown", function(cmCfg, modeCfg) {
...
@@ -58,20 +58,28 @@ CodeMirror.defineMode("mitx_markdown", function(cmCfg, modeCfg) {
,
strong
=
'strong'
,
strong
=
'strong'
,
emstrong
=
'emstrong'
;
,
emstrong
=
'emstrong'
;
function
escapeHtml
(
unsafe
)
{
return
unsafe
.
replace
(
/&/g
,
"&"
)
.
replace
(
/</g
,
"<"
)
.
replace
(
/>/g
,
">"
)
.
replace
(
/"/g
,
"""
)
.
replace
(
/'/g
,
"'"
);
}
var
circuit_formatter
=
{
var
circuit_formatter
=
{
creator
:
function
(
text
)
{
creator
:
function
(
text
)
{
var
circuit_value
=
text
.
match
(
circuitRE
)[
1
]
var
circuit_value
=
text
.
match
(
circuitRE
)[
1
]
//TODO: We need real html escaping here
circuit_value
=
escapeHtml
(
circuit_value
);
circuit_value
=
CodeMirror
.
htmlEscape
(
circuit_value
);
// circuit_value.replace("\"", "'");
var
html
=
"<a href='#circuit_editor' rel='leanModal' class='schematic_open' style='display:inline-block;'>"
+
var
html
=
"<a href='#circuit_editor' rel='leanModal' class='schematic_open' style='display:inline-block;'>"
+
"<input type='hidden' parts='' value='"
+
circuit_value
+
"' width='150' height='1
50
' analyses='' class='schematic ctrls'/></a>"
;
"<input type='hidden' parts='' value='"
+
circuit_value
+
"' width='150' height='1
48
' analyses='' class='schematic ctrls'/></a>"
;
return
html
;
return
html
;
},
},
size
:
function
(
text
)
{
size
:
function
(
text
)
{
return
{
width
:
150
,
height
:
15
4
};
return
{
width
:
150
,
height
:
15
2
};
},
},
callback
:
function
(
node
,
line
)
{
callback
:
function
(
node
,
line
)
{
update_schematics
();
update_schematics
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment