0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-08 03:12:40 +00:00

Merge branch 'master' into Issue_1958

This commit is contained in:
David Bolack
2024-05-20 13:36:41 -05:00
7 changed files with 216 additions and 203 deletions

View File

@@ -14,6 +14,9 @@ const NotificationPopup = require('./notificationPopup/notificationPopup.jsx');
const Frame = require('react-frame-component').default; const Frame = require('react-frame-component').default;
const dedent = require('dedent-tabs').default; const dedent = require('dedent-tabs').default;
const DOMPurify = require('dompurify');
const purifyConfig = { FORCE_BODY: true, SANITIZE_DOM: false };
const Themes = require('themes/themes.json'); const Themes = require('themes/themes.json');
const PAGE_HEIGHT = 1056; const PAGE_HEIGHT = 1056;
@@ -33,8 +36,9 @@ const BrewPage = (props)=>{
index : 0, index : 0,
...props ...props
}; };
const cleanText = DOMPurify.sanitize(props.contents, purifyConfig);
return <div className={props.className} id={`p${props.index + 1}`} > return <div className={props.className} id={`p${props.index + 1}`} >
<div className='columnWrapper' dangerouslySetInnerHTML={{ __html: props.contents }} /> <div className='columnWrapper' dangerouslySetInnerHTML={{ __html: cleanText }} />
</div>; </div>;
}; };
@@ -102,13 +106,6 @@ const BrewRenderer = (props)=>{
return false; return false;
}; };
const sanitizeScriptTags = (content)=>{
return content
?.replace(/<script/ig, '&lt;script')
.replace(/<\/script>/ig, '&lt;/script&gt;')
|| '';
};
const renderPageInfo = ()=>{ const renderPageInfo = ()=>{
return <div className='pageInfo' ref={mainRef}> return <div className='pageInfo' ref={mainRef}>
<div> <div>
@@ -128,19 +125,18 @@ const BrewRenderer = (props)=>{
const renderStyle = ()=>{ const renderStyle = ()=>{
if(!props.style) return; if(!props.style) return;
const cleanStyle = sanitizeScriptTags(props.style); const cleanStyle = DOMPurify.sanitize(props.style, purifyConfig);
//return <div style={{ display: 'none' }} dangerouslySetInnerHTML={{ __html: `<style>@layer styleTab {\n${sanitizeScriptTags(props.style)}\n} </style>` }} />; //return <div style={{ display: 'none' }} dangerouslySetInnerHTML={{ __html: `<style>@layer styleTab {\n${sanitizeScriptTags(props.style)}\n} </style>` }} />;
return <div style={{ display: 'none' }} dangerouslySetInnerHTML={{ __html: `<style> ${cleanStyle} </style>` }} />; return <div style={{ display: 'none' }} dangerouslySetInnerHTML={{ __html: `<style> ${cleanStyle} </style>` }} />;
}; };
const renderPage = (pageText, index)=>{ const renderPage = (pageText, index)=>{
let cleanPageText = sanitizeScriptTags(pageText);
if(props.renderer == 'legacy') { if(props.renderer == 'legacy') {
const html = MarkdownLegacy.render(cleanPageText); const html = MarkdownLegacy.render(pageText);
return <BrewPage className='page phb' index={index} key={index} contents={html} />; return <BrewPage className='page phb' index={index} key={index} contents={html} />;
} else { } else {
cleanPageText += `\n\n&nbsp;\n\\column\n&nbsp;`; //Artificial column break at page end to emulate column-fill:auto (until `wide` is used, when column-fill:balance will reappear) pageText += `\n\n&nbsp;\n\\column\n&nbsp;`; //Artificial column break at page end to emulate column-fill:auto (until `wide` is used, when column-fill:balance will reappear)
const html = Markdown.render(cleanPageText, index); const html = Markdown.render(pageText, index);
return <BrewPage className='page' index={index} key={index} contents={html} />; return <BrewPage className='page' index={index} key={index} contents={html} />;
} }
}; };
@@ -211,11 +207,11 @@ const BrewRenderer = (props)=>{
<RenderWarnings /> <RenderWarnings />
<NotificationPopup /> <NotificationPopup />
</div> </div>
<link href={`/themes/${rendererPath}/Blank/style.css`} type="text/css" rel='stylesheet'/> <link href={`/themes/${rendererPath}/Blank/style.css`} type='text/css' rel='stylesheet'/>
{baseThemePath && {baseThemePath &&
<link href={`/themes/${rendererPath}/${baseThemePath}/style.css`} type="text/css" rel='stylesheet'/> <link href={`/themes/${rendererPath}/${baseThemePath}/style.css`} type='text/css' rel='stylesheet'/>
} }
<link href={`/themes/${rendererPath}/${themePath}/style.css`} type="text/css" rel='stylesheet'/> <link href={`/themes/${rendererPath}/${themePath}/style.css`} type='text/css' rel='stylesheet'/>
{/* Apply CSS from Style tab and render pages from Markdown tab */} {/* Apply CSS from Style tab and render pages from Markdown tab */}
{state.isMounted {state.isMounted

70
package-lock.json generated
View File

@@ -21,6 +21,7 @@
"cookie-parser": "^1.4.6", "cookie-parser": "^1.4.6",
"create-react-class": "^15.7.0", "create-react-class": "^15.7.0",
"dedent-tabs": "^0.10.3", "dedent-tabs": "^0.10.3",
"dompurify": "^3.1.1",
"expr-eval": "^2.0.2", "expr-eval": "^2.0.2",
"express": "^4.19.2", "express": "^4.19.2",
"express-async-handler": "^1.2.0", "express-async-handler": "^1.2.0",
@@ -37,7 +38,7 @@
"marked-smartypants-lite": "^1.0.2", "marked-smartypants-lite": "^1.0.2",
"markedLegacy": "npm:marked@^0.3.19", "markedLegacy": "npm:marked@^0.3.19",
"moment": "^2.30.1", "moment": "^2.30.1",
"mongoose": "^8.3.3", "mongoose": "^8.4.0",
"nanoid": "3.3.4", "nanoid": "3.3.4",
"nconf": "^0.12.1", "nconf": "^0.12.1",
"react": "^18.3.1", "react": "^18.3.1",
@@ -2812,9 +2813,9 @@
} }
}, },
"node_modules/@mongodb-js/saslprep": { "node_modules/@mongodb-js/saslprep": {
"version": "1.1.5", "version": "1.1.7",
"resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.5.tgz", "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.7.tgz",
"integrity": "sha512-XLNOMH66KhJzUJNwT/qlMnS4WsNDWD5ASdyaSH3EtK+F4r/CFGa3jT4GNi4mfOitGvWXtdLgQJkQjxSVrio+jA==", "integrity": "sha512-dCHW/oEX0KJ4NjDULBo3JiOaK5+6axtpBbS+ao2ZInoAL9/YRQLhXzSNAFz7hP4nzLkIqsfYAK/PDE3+XHny0Q==",
"dependencies": { "dependencies": {
"sparse-bitfield": "^3.0.3" "sparse-bitfield": "^3.0.3"
} }
@@ -3002,9 +3003,9 @@
"integrity": "sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA==" "integrity": "sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA=="
}, },
"node_modules/@types/whatwg-url": { "node_modules/@types/whatwg-url": {
"version": "11.0.4", "version": "11.0.5",
"resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-11.0.4.tgz", "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-11.0.5.tgz",
"integrity": "sha512-lXCmTWSHJvf0TRSO58nm978b8HJ/EdsSsEKLd3ODHFjo+3VGAyyTp4v50nWvwtzBxSMQrVOK7tcuN0zGPLICMw==", "integrity": "sha512-coYR071JRaHa+xoEvvYqvnIHaVqaYrLPbsufM9BF63HkwI5Lgmy2QR8Q5K/lYDYo5AK82wOvSOS0UsLTpTG7uQ==",
"dependencies": { "dependencies": {
"@types/webidl-conversions": "*" "@types/webidl-conversions": "*"
} }
@@ -4326,9 +4327,9 @@
} }
}, },
"node_modules/bson": { "node_modules/bson": {
"version": "6.6.0", "version": "6.7.0",
"resolved": "https://registry.npmjs.org/bson/-/bson-6.6.0.tgz", "resolved": "https://registry.npmjs.org/bson/-/bson-6.7.0.tgz",
"integrity": "sha512-BVINv2SgcMjL4oYbBuCQTpE3/VKOSxrOA8Cj/wQP7izSzlBGVomdm+TcUd0Pzy0ytLSSDweCKQ6X3f5veM5LQA==", "integrity": "sha512-w2IquM5mYzYZv6rs3uN2DZTOBe2a0zXLj53TGDqwF4l6Sz/XsISrisXOJihArF9+BZ6Cq/GjVht7Sjfmri7ytQ==",
"engines": { "engines": {
"node": ">=16.20.1" "node": ">=16.20.1"
} }
@@ -5414,6 +5415,11 @@
"npm": ">=1.2" "npm": ">=1.2"
} }
}, },
"node_modules/dompurify": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.1.1.tgz",
"integrity": "sha512-tVP8C/GJwnABOn/7cx/ymx/hXpmBfWIPihC1aOEvS8GbMqy3pgeYtJk1HXN3CO7tu+8bpY18f6isjR5Cymj0TQ=="
},
"node_modules/duplexer2": { "node_modules/duplexer2": {
"version": "0.1.4", "version": "0.1.4",
"resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz",
@@ -10546,26 +10552,26 @@
} }
}, },
"node_modules/mongodb-connection-string-url": { "node_modules/mongodb-connection-string-url": {
"version": "3.0.0", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-3.0.0.tgz", "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-3.0.1.tgz",
"integrity": "sha512-t1Vf+m1I5hC2M5RJx/7AtxgABy1cZmIPQRMXw+gEIPn/cZNF3Oiy+l0UIypUwVB5trcWHq3crg2g3uAR9aAwsQ==", "integrity": "sha512-XqMGwRX0Lgn05TDB4PyG2h2kKO/FfWJyCzYQbIhXUxz7ETt0I/FqHjUeqj37irJ+Dl1ZtU82uYyj14u2XsZKfg==",
"dependencies": { "dependencies": {
"@types/whatwg-url": "^11.0.2", "@types/whatwg-url": "^11.0.2",
"whatwg-url": "^13.0.0" "whatwg-url": "^13.0.0"
} }
}, },
"node_modules/mongoose": { "node_modules/mongoose": {
"version": "8.3.3", "version": "8.4.0",
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-8.3.3.tgz", "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-8.4.0.tgz",
"integrity": "sha512-3kSk0db9DM2tLttCdS6WNRqewPleamFEa4Vz/Qldc0dB4Zow/FiZxb9GExHTJjBZQ9T2xiGleQ3GzRrES3hhsA==", "integrity": "sha512-fgqRMwVEP1qgRYfh+tUe2YBBFnPO35FIg2lfFH+w9IhRGg1/ataWGIqvf/MjwM29cZ60D5vSnqtN2b8Qp0sOZA==",
"dependencies": { "dependencies": {
"bson": "^6.5.0", "bson": "^6.7.0",
"kareem": "2.6.3", "kareem": "2.6.3",
"mongodb": "6.5.0", "mongodb": "6.6.2",
"mpath": "0.9.0", "mpath": "0.9.0",
"mquery": "5.0.0", "mquery": "5.0.0",
"ms": "2.1.3", "ms": "2.1.3",
"sift": "16.0.1" "sift": "17.1.3"
}, },
"engines": { "engines": {
"node": ">=16.20.1" "node": ">=16.20.1"
@@ -10633,12 +10639,12 @@
} }
}, },
"node_modules/mongoose/node_modules/mongodb": { "node_modules/mongoose/node_modules/mongodb": {
"version": "6.5.0", "version": "6.6.2",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.5.0.tgz", "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.6.2.tgz",
"integrity": "sha512-Fozq68InT+JKABGLqctgtb8P56pRrJFkbhW0ux+x1mdHeyinor8oNzJqwLjV/t5X5nJGfTlluxfyMnOXNggIUA==", "integrity": "sha512-ZF9Ugo2JCG/GfR7DEb4ypfyJJyiKbg5qBYKRintebj8+DNS33CyGMkWbrS9lara+u+h+yEOGSRiLhFO/g1s1aw==",
"dependencies": { "dependencies": {
"@mongodb-js/saslprep": "^1.1.5", "@mongodb-js/saslprep": "^1.1.5",
"bson": "^6.4.0", "bson": "^6.7.0",
"mongodb-connection-string-url": "^3.0.0" "mongodb-connection-string-url": "^3.0.0"
}, },
"engines": { "engines": {
@@ -12728,9 +12734,9 @@
} }
}, },
"node_modules/sift": { "node_modules/sift": {
"version": "16.0.1", "version": "17.1.3",
"resolved": "https://registry.npmjs.org/sift/-/sift-16.0.1.tgz", "resolved": "https://registry.npmjs.org/sift/-/sift-17.1.3.tgz",
"integrity": "sha512-Wv6BjQ5zbhW7VFefWusVP33T/EM0vYikCaQ2qR8yULbsilAT8/wQaXvuQ3ptGLpoKx+lihJE3y2UTgKDyyNHZQ==" "integrity": "sha512-Rtlj66/b0ICeFzYTuNvX/EF1igRbbnGSvEyT79McoZa/DeGhMyC5pWKOEsZKnpkqtSeovd5FL/bjHWC3CIIvCQ=="
}, },
"node_modules/signal-exit": { "node_modules/signal-exit": {
"version": "3.0.7", "version": "3.0.7",
@@ -14458,12 +14464,14 @@
} }
}, },
"node_modules/vitreum": { "node_modules/vitreum": {
"version": "6.0.1", "version": "6.0.4",
"resolved": "git+https://git@github.com/calculuschild/vitreum.git#49994da4055f914269318b2b9ae953707aa771b6", "resolved": "git+https://git@github.com/calculuschild/vitreum.git#9d55fd6fb7e85e7070de798c4f9d5b983c1b7dba",
"integrity": "sha512-6b5A4XEXnpyl6JDRWWOhe5lHxtzMVqNA+0Xrl7mPXqh7cYwTUm0yhkYEUkV+mz7rrHTpH7bYEWYsWEE/qTZMpg==",
"hasInstallScript": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"browserify": "^16.5.0", "browserify": "^16.5.0",
"fs-extra": "^9.0.0", "fs-extra": "^9.0.1",
"livereload": "^0.9.1", "livereload": "^0.9.1",
"nodemon": "^2.0.2", "nodemon": "^2.0.2",
"source-map-support": "^0.5.16", "source-map-support": "^0.5.16",
@@ -14474,8 +14482,8 @@
"@babel/core": "^7.9.0", "@babel/core": "^7.9.0",
"@babel/preset-react": "^7.9.4", "@babel/preset-react": "^7.9.4",
"less": "^3.11.1", "less": "^3.11.1",
"react": ">=16.13.1", "react": "^18.3.1",
"react-dom": ">=16.13.1" "react-dom": "^18.3.1"
} }
}, },
"node_modules/vitreum/node_modules/fs-extra": { "node_modules/vitreum/node_modules/fs-extra": {

View File

@@ -93,6 +93,7 @@
"cookie-parser": "^1.4.6", "cookie-parser": "^1.4.6",
"create-react-class": "^15.7.0", "create-react-class": "^15.7.0",
"dedent-tabs": "^0.10.3", "dedent-tabs": "^0.10.3",
"dompurify": "^3.1.1",
"expr-eval": "^2.0.2", "expr-eval": "^2.0.2",
"express": "^4.19.2", "express": "^4.19.2",
"express-async-handler": "^1.2.0", "express-async-handler": "^1.2.0",
@@ -109,7 +110,7 @@
"marked-smartypants-lite": "^1.0.2", "marked-smartypants-lite": "^1.0.2",
"markedLegacy": "npm:marked@^0.3.19", "markedLegacy": "npm:marked@^0.3.19",
"moment": "^2.30.1", "moment": "^2.30.1",
"mongoose": "^8.3.3", "mongoose": "^8.4.0",
"nanoid": "3.3.4", "nanoid": "3.3.4",
"nconf": "^0.12.1", "nconf": "^0.12.1",
"react": "^18.3.1", "react": "^18.3.1",

View File

@@ -171,7 +171,7 @@ module.exports = {
**Condition Immunities** :: ${genList(['groggy', 'swagged', 'weak-kneed', 'buzzed', 'groovy', 'melancholy', 'drunk'], 3)} **Condition Immunities** :: ${genList(['groggy', 'swagged', 'weak-kneed', 'buzzed', 'groovy', 'melancholy', 'drunk'], 3)}
**Senses** :: darkvision 60 ft., passive Perception ${_.random(3, 20)} **Senses** :: darkvision 60 ft., passive Perception ${_.random(3, 20)}
**Languages** :: ${genList(['Common', 'Pottymouth', 'Gibberish', 'Latin', 'Jive'], 2)} **Languages** :: ${genList(['Common', 'Pottymouth', 'Gibberish', 'Latin', 'Jive'], 2)}
**Challenge** :: ${_.random(0, 15)} (${_.random(10, 10000)} XP) **Challenge** :: ${_.random(0, 15)} (${_.random(10, 10000)} XP) {{bonus **Proficiency Bonus** +${_.random(2, 6)}}}
___ ___
${_.times(_.random(genLines, genLines + 2), function(){return genAbilities();}).join('\n:\n')} ${_.times(_.random(genLines, genLines + 2), function(){return genAbilities();}).join('\n:\n')}
: :

View File

@@ -354,6 +354,11 @@
} }
} }
.bonus {
float: right;
padding-right: 0.5em;
}
// Monster Ability table // Monster Ability table
hr + table:first-of-type { hr + table:first-of-type {
margin : 0; margin : 0;

View File

@@ -105,6 +105,7 @@ const elderberryInn = {
'ei_action1' : 'ei action-1', 'ei_action1' : 'ei action-1',
'ei_alter_self' : 'ei alter-self', 'ei_alter_self' : 'ei alter-self',
'ei_alter_self2' : 'ei alter-self-2', 'ei_alter_self2' : 'ei alter-self-2',
'ei_magic_beans' : 'ei magic-beans',
'ei_animal_friendship' : 'ei animal-friendship', 'ei_animal_friendship' : 'ei animal-friendship',
'ei_animate_dead' : 'ei animate-dead', 'ei_animate_dead' : 'ei animate-dead',
'ei_animate_objects' : 'ei animate-objects', 'ei_animate_objects' : 'ei animate-objects',

View File

@@ -59,6 +59,7 @@
&.frightened::before { content : '\E922'; } &.frightened::before { content : '\E922'; }
&.grappled::before { content : '\E923'; } &.grappled::before { content : '\E923'; }
&.incapacitated::before { content : '\E924'; } &.incapacitated::before { content : '\E924'; }
&.unconscious::before { content : '\E925'; }
&.invisible::before { content : '\E926'; } &.invisible::before { content : '\E926'; }
&.paralyzed::before { content : '\E927'; } &.paralyzed::before { content : '\E927'; }
&.petrified::before { content : '\E928'; } &.petrified::before { content : '\E928'; }
@@ -66,7 +67,7 @@
&.prone::before { content : '\E92A'; } &.prone::before { content : '\E92A'; }
&.restrained::before { content : '\E92B'; } &.restrained::before { content : '\E92B'; }
&.stunned::before { content : '\E92C'; } &.stunned::before { content : '\E92C'; }
&.unconscious::before { content : '\E925'; }
/* Character Classes and Features */ /* Character Classes and Features */
&.barbarian-rage::before { content : '\E92D'; } &.barbarian-rage::before { content : '\E92D'; }
@@ -82,7 +83,7 @@
&.monk-step-of-the-wind-2::before { content : '\E937'; } &.monk-step-of-the-wind-2::before { content : '\E937'; }
&.monk-step-of-the-wind-3::before { content : '\E938'; } &.monk-step-of-the-wind-3::before { content : '\E938'; }
&.monk-stunning-strike::before { content : '\E939'; } &.monk-stunning-strike::before { content : '\E939'; }
&.monk-stunning-strike-2::before { content : '\E939'; } &.monk-stunning-strike-2::before { content : '\E93A'; }
&.paladin-divine-smite::before { content : '\E93B'; } &.paladin-divine-smite::before { content : '\E93B'; }
&.paladin-lay-on-hands::before { content : '\E93C'; } &.paladin-lay-on-hands::before { content : '\E93C'; }
&.barbarian-abilities::before { content : '\E93D'; } &.barbarian-abilities::before { content : '\E93D'; }
@@ -121,6 +122,7 @@
&.action-1::before { content : '\E95A'; } &.action-1::before { content : '\E95A'; }
&.alter-self::before { content : '\E95B'; } &.alter-self::before { content : '\E95B'; }
&.alter-self-2::before { content : '\E95C'; } &.alter-self-2::before { content : '\E95C'; }
&.magic-beans::before { content : '\E95D'; }
&.animal-friendship::before { content : '\E95E'; } &.animal-friendship::before { content : '\E95E'; }
&.animate-dead::before { content : '\E95F'; } &.animate-dead::before { content : '\E95F'; }
&.animate-objects::before { content : '\E960'; } &.animate-objects::before { content : '\E960'; }