mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 11:36:44 +00:00
- Prevent barcode data from being "escaped" - Run through bleach to brevent malicious data injection (cherry picked from commit b1d9a2392884edc6135a247022d74792cb993b78) Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
parent
3659bbe389
commit
cebad3d142
@ -3,6 +3,7 @@
|
|||||||
{% load static %}
|
{% load static %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load generic %}
|
{% load generic %}
|
||||||
|
{% load barcode %}
|
||||||
{% load inventree_extras %}
|
{% load inventree_extras %}
|
||||||
|
|
||||||
{% block page_title %}
|
{% block page_title %}
|
||||||
@ -277,7 +278,7 @@ src="{% static 'img/blank_image.png' %}"
|
|||||||
$('#show-qr-code').click(function() {
|
$('#show-qr-code').click(function() {
|
||||||
showQRDialog(
|
showQRDialog(
|
||||||
'{% trans "Build Order QR Code" escape %}',
|
'{% trans "Build Order QR Code" escape %}',
|
||||||
'{{ build.barcode }}'
|
`{% clean_barcode build.barcode %}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{% extends "page_base.html" %}
|
{% extends "page_base.html" %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
{% load barcode %}
|
||||||
{% load inventree_extras %}
|
{% load inventree_extras %}
|
||||||
|
|
||||||
{% block page_title %}
|
{% block page_title %}
|
||||||
@ -303,7 +304,7 @@ onPanelLoad('supplier-part-notes', function() {
|
|||||||
$("#show-qr-code").click(function() {
|
$("#show-qr-code").click(function() {
|
||||||
showQRDialog(
|
showQRDialog(
|
||||||
'{% trans "Supplier Part QR Code" escape %}',
|
'{% trans "Supplier Part QR Code" escape %}',
|
||||||
'{{ part.barcode }}'
|
`{% clean_barcode part.barcode %}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
|
{% load barcode %}
|
||||||
{% load inventree_extras %}
|
{% load inventree_extras %}
|
||||||
{% load generic %}
|
{% load generic %}
|
||||||
|
|
||||||
@ -312,7 +313,7 @@ $("#export-order").click(function() {
|
|||||||
$('#show-qr-code').click(function() {
|
$('#show-qr-code').click(function() {
|
||||||
showQRDialog(
|
showQRDialog(
|
||||||
'{% trans "Purchase Order QR Code" escape %}',
|
'{% trans "Purchase Order QR Code" escape %}',
|
||||||
'{{ order.barcode }}'
|
`{% clean_barcode order.barcode %}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
|
{% load barcode %}
|
||||||
{% load inventree_extras %}
|
{% load inventree_extras %}
|
||||||
{% load generic %}
|
{% load generic %}
|
||||||
|
|
||||||
@ -257,7 +258,7 @@ $('#print-order-report').click(function() {
|
|||||||
$('#show-qr-code').click(function() {
|
$('#show-qr-code').click(function() {
|
||||||
showQRDialog(
|
showQRDialog(
|
||||||
'{% trans "Return Order QR Code" escape %}',
|
'{% trans "Return Order QR Code" escape %}',
|
||||||
'{{ order.barcode }}'
|
`{% clean_barcode order.barcode %}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
|
{% load barcode %}
|
||||||
{% load inventree_extras %}
|
{% load inventree_extras %}
|
||||||
{% load generic %}
|
{% load generic %}
|
||||||
|
|
||||||
@ -319,7 +320,7 @@ $('#print-order-report').click(function() {
|
|||||||
$('#show-qr-code').click(function() {
|
$('#show-qr-code').click(function() {
|
||||||
showQRDialog(
|
showQRDialog(
|
||||||
'{% trans "Sales Order QR Code" escape %}',
|
'{% trans "Sales Order QR Code" escape %}',
|
||||||
'{{ order.barcode }}'
|
`{% clean_barcode order.barcode %}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
{% load barcode %}
|
||||||
{% load inventree_extras %}
|
{% load inventree_extras %}
|
||||||
|
|
||||||
{% block sidebar %}
|
{% block sidebar %}
|
||||||
@ -451,7 +452,7 @@
|
|||||||
$("#show-qr-code").click(function() {
|
$("#show-qr-code").click(function() {
|
||||||
showQRDialog(
|
showQRDialog(
|
||||||
'{% trans "Part QR Code" escape %}',
|
'{% trans "Part QR Code" escape %}',
|
||||||
'{{ part.barcode|safe }}',
|
`{% clean_barcode part.barcode %}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
"""Template tags for rendering various barcodes."""
|
"""Template tags for rendering various barcodes."""
|
||||||
|
|
||||||
from django import template
|
from django import template
|
||||||
|
from django.utils.safestring import mark_safe
|
||||||
|
|
||||||
import barcode as python_barcode
|
import barcode as python_barcode
|
||||||
import qrcode.constants as ECL
|
import qrcode.constants as ECL
|
||||||
@ -26,6 +27,23 @@ def image_data(img, fmt='PNG'):
|
|||||||
return report.helpers.encode_image_base64(img, fmt)
|
return report.helpers.encode_image_base64(img, fmt)
|
||||||
|
|
||||||
|
|
||||||
|
@register.simple_tag()
|
||||||
|
def clean_barcode(data):
|
||||||
|
"""Return a 'cleaned' string for encoding into a barcode / qrcode.
|
||||||
|
|
||||||
|
- This function runs the data through bleach, and removes any malicious HTML content.
|
||||||
|
- Used to render raw barcode data into the rendered HTML templates
|
||||||
|
"""
|
||||||
|
from InvenTree.helpers import strip_html_tags
|
||||||
|
|
||||||
|
cleaned_date = strip_html_tags(data)
|
||||||
|
|
||||||
|
# Remove back-tick character (prevent injection)
|
||||||
|
cleaned_date = cleaned_date.replace('`', '')
|
||||||
|
|
||||||
|
return mark_safe(cleaned_date)
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag()
|
@register.simple_tag()
|
||||||
def qrcode(data, **kwargs):
|
def qrcode(data, **kwargs):
|
||||||
"""Return a byte-encoded QR code image.
|
"""Return a byte-encoded QR code image.
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
{% load plugin_extras %}
|
{% load plugin_extras %}
|
||||||
{% load inventree_extras %}
|
{% load inventree_extras %}
|
||||||
{% load generic %}
|
{% load generic %}
|
||||||
|
{% load barcode %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load l10n %}
|
{% load l10n %}
|
||||||
|
|
||||||
@ -534,7 +535,7 @@ $('#stock-edit-status').click(function () {
|
|||||||
$("#show-qr-code").click(function() {
|
$("#show-qr-code").click(function() {
|
||||||
showQRDialog(
|
showQRDialog(
|
||||||
'{% trans "Stock Item QR Code" escape %}',
|
'{% trans "Stock Item QR Code" escape %}',
|
||||||
'{{ item.barcode }}',
|
`{% clean_barcode item.barcode %}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{% extends "stock/stock_app_base.html" %}
|
{% extends "stock/stock_app_base.html" %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
|
{% load barcode %}
|
||||||
{% load inventree_extras %}
|
{% load inventree_extras %}
|
||||||
{% load plugin_extras %}
|
{% load plugin_extras %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
@ -391,7 +392,7 @@
|
|||||||
$('#show-qr-code').click(function() {
|
$('#show-qr-code').click(function() {
|
||||||
showQRDialog(
|
showQRDialog(
|
||||||
'{% trans "Stock Location QR Code" escape %}',
|
'{% trans "Stock Location QR Code" escape %}',
|
||||||
'{{ location.barcode }}'
|
`{% clean_barcode location.barcode %}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user