[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Use underscore's implementation of escape

2018-01-19 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/405350 )

Change subject: Use underscore's implementation of escape
..


Use underscore's implementation of escape

The underscore implementation handles a few more characters than ours
did.

Change-Id: Ic029bae9f8f9ad10b35bdbc41fb8a2346b0d6bf8
---
M lib/transformations/extractLeadIntroduction.js
1 file changed, 2 insertions(+), 19 deletions(-)

Approvals:
  jenkins-bot: Verified
  Mholloway: Looks good to me, approved



diff --git a/lib/transformations/extractLeadIntroduction.js 
b/lib/transformations/extractLeadIntroduction.js
index f586951..7661b2c 100644
--- a/lib/transformations/extractLeadIntroduction.js
+++ b/lib/transformations/extractLeadIntroduction.js
@@ -1,6 +1,7 @@
 'use strict';
 
 const NodeType = require('../nodeType');
+const _ = require('underscore');
 
 /*
  * Check whether a node has any content.
@@ -10,24 +11,6 @@
 function isEmpty(node) {
 return node.textContent.trim().length === 0;
 }
-
-/*
- * HTML escape a string.
- * @param {!String} s
- * @return {!String}
- */
-function escape(s) {
-return s.replace(/[&<>"']/g, (c) => {
-switch (c) {
-case '&': return '';
-case '<': return '';
-case '>': return '';
-case '"': return '';
-default: return;
-}
-});
-}
-
 
 /*
  * Extracts the first non-empty paragraph from an article and any
@@ -56,7 +39,7 @@
 // Deal with text nodes
 if (nextSibling.nodeType === NodeType.TEXT_NODE) {
 if (!isEmpty(nextSibling)) {
-p += escape(nextSibling.textContent);
+p += _.escape(nextSibling.textContent);
 }
 } else {
 p += nextSibling.outerHTML;

-- 
To view, visit https://gerrit.wikimedia.org/r/405350
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic029bae9f8f9ad10b35bdbc41fb8a2346b0d6bf8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 
Gerrit-Reviewer: Fjalapeno 
Gerrit-Reviewer: Jdlrobson 
Gerrit-Reviewer: Mholloway 
Gerrit-Reviewer: Mhurd 
Gerrit-Reviewer: Ppchelko 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Use underscore's implementation of escape

2018-01-19 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405350 )

Change subject: Use underscore's implementation of escape
..

Use underscore's implementation of escape

The underscore implementation handles a few more characters than ours
did.

Change-Id: Ic029bae9f8f9ad10b35bdbc41fb8a2346b0d6bf8
---
M lib/transformations/extractLeadIntroduction.js
1 file changed, 2 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/50/405350/1

diff --git a/lib/transformations/extractLeadIntroduction.js 
b/lib/transformations/extractLeadIntroduction.js
index f586951..7661b2c 100644
--- a/lib/transformations/extractLeadIntroduction.js
+++ b/lib/transformations/extractLeadIntroduction.js
@@ -1,6 +1,7 @@
 'use strict';
 
 const NodeType = require('../nodeType');
+const _ = require('underscore');
 
 /*
  * Check whether a node has any content.
@@ -10,24 +11,6 @@
 function isEmpty(node) {
 return node.textContent.trim().length === 0;
 }
-
-/*
- * HTML escape a string.
- * @param {!String} s
- * @return {!String}
- */
-function escape(s) {
-return s.replace(/[&<>"']/g, (c) => {
-switch (c) {
-case '&': return '';
-case '<': return '';
-case '>': return '';
-case '"': return '';
-default: return;
-}
-});
-}
-
 
 /*
  * Extracts the first non-empty paragraph from an article and any
@@ -56,7 +39,7 @@
 // Deal with text nodes
 if (nextSibling.nodeType === NodeType.TEXT_NODE) {
 if (!isEmpty(nextSibling)) {
-p += escape(nextSibling.textContent);
+p += _.escape(nextSibling.textContent);
 }
 } else {
 p += nextSibling.outerHTML;

-- 
To view, visit https://gerrit.wikimedia.org/r/405350
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic029bae9f8f9ad10b35bdbc41fb8a2346b0d6bf8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits