File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,13 +27,15 @@ Bugfixes & Improvements
2727- Prevent auto creation of invalid links in comments (`#995 `_, pkvach)
2828- Fix W3C Validation issues (`#999 `_, pkvach)
2929- Handle deleted comments in Disqus migration (`#994 `_, pkvach)
30+ - Fix newline character handling in data-isso-* i18n strings (`#992 `_, pkvach)
3031
3132.. _#951 : https://github.com/posativ/isso/pull/951
3233.. _#967 : https://github.com/posativ/isso/pull/967
3334.. _#983 : https://github.com/posativ/isso/pull/983
3435.. _#995 : https://github.com/isso-comments/isso/pull/995
3536.. _#999 : https://github.com/isso-comments/isso/pull/999
3637.. _#994 : https://github.com/isso-comments/isso/pull/994
38+ .. _#992 : https://github.com/isso-comments/isso/pull/992
3739
38400.13.1.dev0 (2023-02-05)
3941------------------------
Original file line number Diff line number Diff line change @@ -16,6 +16,10 @@ for (var i = 0; i < js.length; i++) {
1616 for ( var j = 0 ; j < js [ i ] . attributes . length ; j ++ ) {
1717 var attr = js [ i ] . attributes [ j ] ;
1818 if ( / ^ d a t a - i s s o - / . test ( attr . name ) ) {
19+
20+ // Replace escaped newline characters in the attribute value with actual newline characters
21+ const attrValue = attr . value . replace ( / \\ n / g, '\n' ) ;
22+
1923 try {
2024 // Normalize underscores to dashes so that language-specific
2125 // strings can be caught better later on,
@@ -27,11 +31,11 @@ for (var i = 0; i < js.length; i++) {
2731 // not follow that convention, convert to lowercase here anyway.
2832 config [ attr . name . substring ( 10 )
2933 . replace ( / _ / g, '-' )
30- . toLowerCase ( ) ] = JSON . parse ( attr . value ) ;
34+ . toLowerCase ( ) ] = JSON . parse ( attrValue ) ;
3135 } catch ( ex ) {
3236 config [ attr . name . substring ( 10 )
3337 . replace ( / _ / g, '-' )
34- . toLowerCase ( ) ] = attr . value ;
38+ . toLowerCase ( ) ] = attrValue ;
3539 }
3640 }
3741 }
Original file line number Diff line number Diff line change 99
1010"use strict" ;
1111
12+ beforeEach ( ( ) => {
13+ jest . resetModules ( ) ;
14+ document . body . innerHTML = '' ;
15+ } ) ;
16+
1217test ( "Client configuration - no languages" , ( ) => {
1318 // Mock navigator.languages = []
1419 global . languages = jest . spyOn ( navigator , "languages" , "get" )
@@ -35,3 +40,21 @@ test("Client configuration - no languages", () => {
3540
3641 expect ( config [ "langs" ] ) . toStrictEqual ( expected_langs ) ;
3742} ) ;
43+
44+ test ( "data-isso-* i18n strings should be accepted with newline characters" , ( ) => {
45+
46+ document . body . innerHTML =
47+ '<div id=isso-thread></div>' +
48+ // Note: `src` and `data-isso` need to be set,
49+ // else `api` fails to initialize!
50+ '<script src="http://isso.api/js/embed.min.js"'
51+ + ' data-isso="/"'
52+ + '</script>' ;
53+
54+ var script_tag = document . getElementsByTagName ( 'script' ) [ 0 ] ;
55+ script_tag . setAttributeNS ( null , 'data-isso-num-comments-text-en' , "One comment\\n{{ n }} comments" ) ;
56+
57+ const config = require ( "app/config" ) ;
58+
59+ expect ( config [ 'num-comments-text-en' ] ) . toMatch ( "One comment\n{{ n }} comments" ) ;
60+ } ) ;
You can’t perform that action at this time.
0 commit comments