Interesting observation. I may have found a possible explanation.

The error is thrown from the line at [1].

Quote:
            var stemmedWord=stemmer(word);
            if(w[stemmedWord]!=undefined){
                stemQueryMap[stemmer(word)] = word;
            } else {
                stemQueryMap[originalWord]=originalWord;
            }

stemQueryMap is a JavaScript array. 'length' is a default property that
return the number of elements of the given array. An assignment like
*stemQueryMap["length"]
= "length"* will modify this 'length' property. Since the new value is not
an integer, Chrome's Javascript engine goes haywire.

>>  You can recover from this by clearing the cookies. <<

Best possible fix for this is that JS engines should start treating
'length' as a keyword. Since that is a long shot, easiest workaround is to
patch the nwSearchFnt.js IMO - where we ask it to treat '*length*' as a
special keyword.

We should do this for all the Array objects in there such
as stemmedWordsList, cleanwordsList, wordsList.

@Janice, are you interested in sending a GitHub pull request for this? :)

[1]
https://github.com/docbook/xslt10-stylesheets/blob/master/xsl/webhelp/template/search/nwSearchFnt.js#L383
[2]
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length

Best regards,
KasunG

On Tue, Oct 17, 2017 at 9:11 AM, Peter Desjardins <
peter.desjardins...@gmail.com> wrote:

> I can confirm that I see the same behavior in our webhelp. Searching
> for the term "length" will result in the same JS error.
>
> The search function is working as expected otherwise. Interesting problem!
>
> Peter
>
> On Mon, Oct 16, 2017 at 5:00 PM, Janice Manwiller <jan...@sqrrl.com>
> wrote:
> > This issue has been reported by a couple of internal users of our
> WebHelp.
> > Has anyone run into something similar? And if so, any ideas of how to
> > address?
> >
> > I have never seen the behavior myself.
> >
> > Our WebHelp is built using the Maven docbx plugin.
> >
> > When using the WebHelp in Chrome, the user issues a search - in this
> case,
> > specifically for the term "length".
> >
> > They get no results, and the search/contents sidebar disappears. They are
> > unable to get it back unless they restart Chrome, which destroys all of
> > their work in the main application.
> >
> > The Chrome console has the following:
> >
> > nwSearchFnt.js:383 Uncaught RangeError: Invalid array length
> >     at tokenize (nwSearchFnt.js:383)
> >     at Effectuer_recherche (nwSearchFnt.js:158)
> >     at Verifie (nwSearchFnt.js:100)
> >     at HTMLDocument.<anonymous> (main.js:68)
> >     at o (jquery-1.7.2.min.js:2)
> >     at Object.fireWith (jquery-1.7.2.min.js:2)
> >     at Function.ready (jquery-1.7.2.min.js:2)
> >     at HTMLDocument.B (jquery-1.7.2.min.js:2)
> >
> >
> >
> > Any help is appreciated.
> >
> > Thanks,
> >
> > Janice
> >
> > --
> > Janice Manwiller
> > Principal Technical Writer
> > Sqrrl Data, Inc.
> > www.sqrrl.com | @SqrrlData
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: docbook-apps-unsubscr...@lists.oasis-open.org
> For additional commands, e-mail: docbook-apps-h...@lists.oasis-open.org
>
>


-- 
~~~*******'''''''''''''*******~~~
*Kasun Gajasinghe*
Senior Software Engineer; WSO2 Inc.; http://wso2.com,
*Linked-in: *http://lk.linkedin.com/in/gajasinghe
*Blog: **http://blog.kasunbg.org* <http://blog.kasunbg.org/>


*GitHub: **http://github.com/kasunbg* <http://github.com/kasunbg>

Reply via email to