File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,15 +33,13 @@ const CitationModal = ({
3333 ) ;
3434 } ;
3535
36- console . log ( 'CitationModal customTitle = ' , customTitle )
37- console . log ( 'CitationModal titleStyle = ' , titleStyle )
38-
3936 let customQuery = queryConcatenator ( [ query , q_advanced ] ) ;
4037 if ( customQuery . length > 100 ) {
4138 customQuery = customQuery . substr ( 0 , 100 ) + "[..]" ;
4239 }
4340 if ( customTitle ) {
44- customQuery = customTitle ;
41+ // customQuery = customTitle;
42+ customQuery = unescapeHTML ( customTitle ) ;
4543 }
4644
4745 const date = getDateFromTimestamp ( timestamp ) ;
@@ -102,4 +100,25 @@ const mapDispatchToProps = (dispatch) => ({
102100 onClose : ( ) => dispatch ( closeCitationModal ( ) ) ,
103101} ) ;
104102
103+ const unescapeHTML = ( string ) => {
104+ let entityMap = {
105+ "&" : "&" ,
106+ "<" : "<" ,
107+ ">" : ">" ,
108+ """ : '"' ,
109+ """ : '"' ,
110+ "'" : "'" ,
111+ "/" : "/" ,
112+ "`" : "`" ,
113+ "=" : "=" ,
114+ } ;
115+
116+ return String ( string ) . replace (
117+ / ( & a m p ; | & l t ; | & g t ; | & q u o t ; | & # 3 4 ; | & # 3 9 ; | & # x 2 F ; | & # x 6 0 ; | & # x 3 D ; ) / g,
118+ function ( s ) {
119+ return entityMap [ s ] ;
120+ }
121+ ) ;
122+ } ;
123+
105124export default connect ( mapStateToProps , mapDispatchToProps ) ( CitationModal ) ;
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ const StandardKMInfo = ({
1414} ) => {
1515 let queryString = queryConcatenator ( [ query , q_advanced ] )
1616
17+ customTitle = unescapeHTML ( customTitle )
18+
1719 return (
1820 // html template starts here
1921 < >
@@ -89,4 +91,25 @@ const StandardKMInfo = ({
8991 ) ;
9092} ;
9193
94+ const unescapeHTML = ( string ) => {
95+ let entityMap = {
96+ "&" : "&" ,
97+ "<" : "<" ,
98+ ">" : ">" ,
99+ """ : '"' ,
100+ """ : '"' ,
101+ "'" : "'" ,
102+ "/" : "/" ,
103+ "`" : "`" ,
104+ "=" : "=" ,
105+ } ;
106+
107+ return String ( string ) . replace (
108+ / ( & a m p ; | & l t ; | & g t ; | & q u o t ; | & # 3 4 ; | & # 3 9 ; | & # x 2 F ; | & # x 6 0 ; | & # x 3 D ; ) / g,
109+ function ( s ) {
110+ return entityMap [ s ] ;
111+ }
112+ ) ;
113+ } ;
114+
92115export default StandardKMInfo ;
You can’t perform that action at this time.
0 commit comments