Skip to content
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

fix: sanitize error message #195

Merged
merged 2 commits into from
Nov 6, 2024
Merged
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
23 changes: 19 additions & 4 deletions error.vue
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
<Header />
<div class="error-info-container">
<h1 class="error-status-code">{{ error.statusCode }}</h1>
<p class="error-message">{{ error.message }}</p>
<p v-if="error.statusCode !== 404" class="error-message">{{ sanitizedErrorMessage }}</p>
<CommonButton as="RouterLink" :to="{ name: 'bridge' }" class="mt-4" variant="primary">
Back to Bridge
</CommonButton>
@@ -12,14 +12,29 @@
</template>

<script lang="ts">
export default {
import DOMPurify from "dompurify";
import { defineComponent, computed } from "vue";

export default defineComponent({
props: {
error: {
type: Object as PropType<any>,
type: Object as PropType<{ statusCode: number; message: string }>,
required: true,
validator: (value: { statusCode: number; message: string }) => {
return typeof value.statusCode === "number" && typeof value.message === "string";
},
},
},
};
setup(props: { error: { statusCode: number; message: string } }) {
const sanitizedErrorMessage = computed(() => {
return DOMPurify.sanitize(props.error.message);
});

return {
sanitizedErrorMessage,
};
},
});
</script>

<style lang="scss" scoped>
18 changes: 18 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
"prepare": "husky install",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .eslintignore --no-error-on-unmatched-pattern --max-warnings=0",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .eslintignore --no-error-on-unmatched-pattern --max-warnings=2",
"lint:fix": "npm run lint -- --fix"
},
"devDependencies": {
@@ -38,6 +38,7 @@
"@playwright/test": "^1.35.1",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/exec": "^6.0.3",
"@types/dompurify": "^3.0.5",
"@types/node": "^20.11.24",
"@vue/eslint-config-prettier": "^7.1.0",
"@vueuse/core": "^10.9.0",
@@ -77,6 +78,7 @@
"@wagmi/core": "^2.6.5",
"@web3modal/wagmi": "^4.1.3",
"crypto-js": "^4.1.1",
"dompurify": "^3.1.7",
"dotenv": "^16.0.3",
"ethers": "^5.7.2",
"jsqr": "^1.4.0",
1 change: 1 addition & 0 deletions types/dompurify.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module "dompurify";
Loading