Hacker News new | ask | show | jobs
by jampa 1018 days ago
It seems that anything that returns "++" (EDIT: in the "About" box), in this case "Notepad++", breaks their internal regex because it seems not to be sanitized properly

The breaking code using chrome dev tools seems to be:

n = new RegExp("^(https?://)?([\\w\\.-_]\\.)?" + o.toLowerCase().replace(/[-\s]/g, "") + "\\.");

In this case "o" is "Notepad++" which might be the first result.

The browser returns this error:

Invalid regular expression: /^(https?://)?([\w\.-_]\.)?notepad++\./: Nothing to repeat

Also happens with C++ https://duckduckgo.com/?q=c%2B%2B&t=ffab&ia=web

6 comments

Speaking of control characters breaking things, HN ate the * characters in your post and turned the text into italics instead.
its because of markdown formatting
The part of regex

    [\w\.-_]
should really be

    [\w\.\-_]
instead.

But not that's not what caused the problem mentioned in this post.

(edited for clairifcation)

Curious that the error does not occur when searching for "Notepad+": https://duckduckgo.com/?q=notepad%2B&t=ffab&atb=v101-1&ia=we...
In this scenario all the "o" instances are "Notepad+".

The error seems to be coming from the right sidebar which displays "Notepad+" as a title as well. It seems to be getting the "Heading" from the wikipedia page

Here is the object where it extracts the heading from, it seems in this scenario it is not extracting "Notepad++" in the about but "Notepad+" which is another application.

```

Abstract: "Notepad+ is a freeware text editor for Windows operating systems and is intended as a replacement for the Notepad editor installed by default on Windows. It has more formatting features but, like Notepad, works only with plain text. It can open text files of any size, and a single instance of the program can have multiple files open simultaneously. It supports dragging and dropping text within a file and between files, and supports multiple fonts and colours. Notepad+ is available from the company RogSoft. It was developed by Dutch programmer Rogier Meurs. It was first released in 1996. Originally, it had the advantage of being able to open files of any size, because until 2000 Notepad could not open files larger than 64 KB." AbstractSource: "Wikipedia" AbstractURL: "https://en.wikipedia.org/wiki/Notepad%2B" Heading: "Notepad+"

```

It's because a single plus '+' is valid in a regex. A double plus '++' is invalid.
It's not quite anything that returns a '++', but I think any search term that creates a '++' (or perhaps any invalid regex syntax) inside the main info box result.
"cpp" seems to work fine though, and returns many results that include "c++"... https://duckduckgo.com/?q=cpp&t=ffab&ia=web
But "c plus plus" breaks