diff --git a/inc/SP/DataModel/CustomFieldData.class.php b/inc/SP/DataModel/CustomFieldData.class.php
index f4f8fd30..42e26952 100644
--- a/inc/SP/DataModel/CustomFieldData.class.php
+++ b/inc/SP/DataModel/CustomFieldData.class.php
@@ -2,8 +2,8 @@
/**
* sysPass
*
- * @author nuxsmin
- * @link http://syspass.org
+ * @author nuxsmin
+ * @link http://syspass.org
* @copyright 2012-2017, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
@@ -152,6 +152,14 @@ class CustomFieldData extends CustomFieldBaseData
return Html::sanitize($this->value);
}
+ /**
+ * @return string
+ */
+ public function getSafeHtmlValue()
+ {
+ return htmlspecialchars($this->value, ENT_QUOTES);
+ }
+
/**
* @return int
*/
diff --git a/inc/themes/material-blue/views/common/aux-customfields.inc b/inc/themes/material-blue/views/common/aux-customfields.inc
index 823e4ec4..fe6834ad 100644
--- a/inc/themes/material-blue/views/common/aux-customfields.inc
+++ b/inc/themes/material-blue/views/common/aux-customfields.inc
@@ -31,7 +31,7 @@ foreach ($customFields as $index => $field):?>
type="password"
class="mdl-textfield__input mdl-color-text--indigo-400 passwordfield__no-pki "
maxlength="500"
- value="getCleanValue() !== '') ? '***' : $field->getCleanValue(); ?>" getDefinition()->isRequired() ? 'required' : ''; ?> >
+ value="getValue() !== '') ? '***' : $field->getSafeHtmlValue(); ?>" getDefinition()->isRequired() ? 'required' : ''; ?> >
diff --git a/js/app-main.js b/js/app-main.js
index f21f74ba..0d34331d 100644
--- a/js/app-main.js
+++ b/js/app-main.js
@@ -590,45 +590,45 @@ sysPass.Main = function () {
var initializeClipboard = function () {
log.info("initializeClipboard");
- if (!Clipboard.isSupported()) {
+ if (!clipboard.isSupported()) {
log.warn(config.LANG[65]);
return;
}
- var clipboard = new Clipboard(".clip-pass-button", {
- async: function (trigger) {
- var _this = this;
+ $("body").on("click", ".clip-pass-button", function () {
+ var json = appActions.account.copypass($(this)).done(function (json) {
+ sk.set(json.csrf);
+ });
- return appActions.account.copypass($(trigger)).then(function (json) {
- sk.set(json.csrf);
+ clipboard.copy(json.responseJSON.data.accpass).then(
+ function () {
+ msg.ok(config.LANG[45]);
+ },
+ function (err) {
+ msg.error(config.LANG[46]);
+ }
+ );
+ }).on("click", ".dialog-clip-button", function () {
+ var $target = $(this.dataset.clipboardTarget);
- _this.asyncText = json.data.accpass;
- });
- }
- });
-
- clipboard.on("success", function (e) {
- msg.ok(config.LANG[45]);
- }).on("error", function (e) {
- msg.error(config.LANG[46]);
- });
-
- // Portapapeles para claves visualizadas
- var clipboardDialog = new Clipboard(".dialog-clip-button");
-
- clipboardDialog.on("success", function (e) {
- $(".dialog-text").removeClass("dialog-clip-copy");
- $(e.trigger.dataset.clipboardTarget).addClass("dialog-clip-copy");
-
- e.clearSelection();
- });
-
- var clipboardIcon = new Clipboard(".clip-pass-icon");
-
- clipboardIcon.on("success", function (e) {
- msg.ok(config.LANG[45]);
-
- e.clearSelection();
+ clipboard.copy($target.text()).then(
+ function () {
+ $(".dialog-text").removeClass("dialog-clip-copy");
+ $target.addClass("dialog-clip-copy");
+ },
+ function (err) {
+ msg.error(config.LANG[46]);
+ }
+ );
+ }).on("click", ".clip-pass-icon", function () {
+ clipboard.copy(decodeEntities(this.dataset.clipboardText)).then(
+ function () {
+ msg.ok(config.LANG[45]);
+ },
+ function (err) {
+ msg.error(config.LANG[46]);
+ }
+ );
});
};
@@ -770,6 +770,30 @@ sysPass.Main = function () {
return image;
};
+ /**
+ * @author http://stackoverflow.com/users/24950/robert-k
+ * @link http://stackoverflow.com/questions/5796718/html-entity-decode
+ */
+ var decodeEntities = (function () {
+ // this prevents any overhead from creating the object each time
+ var element = document.createElement("div");
+
+ function decodeHTMLEntities(str) {
+ if (str && typeof str === "string") {
+ // strip script/html tags
+ str = str.replace(/