Merge pull request #6431 from Snuffleupagus/issue-6416

Add a utility function, for the viewer, that removes `null` (\x00) characters (issue 6416)
This commit is contained in:
Yury Delendik 2015-09-09 17:08:45 -05:00
commit f1652cb8b7
3 changed files with 10 additions and 3 deletions

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals getFileName */
/* globals getFileName, removeNullCharacters */
'use strict';
@ -91,7 +91,7 @@ var PDFAttachmentView = (function PDFAttachmentViewClosure() {
div.className = 'attachmentsItem';
var button = document.createElement('button');
this._bindLink(button, item.content, filename);
button.textContent = filename;
button.textContent = removeNullCharacters(filename);
div.appendChild(button);
this.container.appendChild(div);
}

View File

@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals removeNullCharacters */
'use strict';
@ -138,7 +139,7 @@ var PDFOutlineView = (function PDFOutlineViewClosure() {
div.className = 'outlineItem';
var element = document.createElement('a');
this._bindLink(element, item);
element.textContent = item.title;
element.textContent = removeNullCharacters(item.title);
div.appendChild(element);
if (item.items.length > 0) {

View File

@ -75,6 +75,12 @@ var CustomStyle = (function CustomStyleClosure() {
return CustomStyle;
})();
var NullCharactersRegExp = /\x00/g;
function removeNullCharacters(str) {
return str.replace(NullCharactersRegExp, '');
}
function getFileName(url) {
var anchor = url.indexOf('#');
var query = url.indexOf('?');