Merge pull request #15835 from Snuffleupagus/viewer-safe-element-access
Protect a few additional DOM element accesses in the viewer (PR 15831 follow-up)
This commit is contained in:
		
						commit
						b518d93b45
					
				
							
								
								
									
										24
									
								
								web/app.js
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								web/app.js
									
									
									
									
									
								
							@ -532,7 +532,7 @@ const PDFViewerApplication = {
 | 
				
			|||||||
      pdfLinkService.setHistory(this.pdfHistory);
 | 
					      pdfLinkService.setHistory(this.pdfHistory);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (appConfig.findBar && !this.supportsIntegratedFind) {
 | 
					    if (!this.supportsIntegratedFind && appConfig.findBar) {
 | 
				
			||||||
      this.findBar = new PDFFindBar(appConfig.findBar, eventBus, this.l10n);
 | 
					      this.findBar = new PDFFindBar(appConfig.findBar, eventBus, this.l10n);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -543,11 +543,8 @@ const PDFViewerApplication = {
 | 
				
			|||||||
          eventBus
 | 
					          eventBus
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        for (const element of [
 | 
					        for (const id of ["editorModeButtons", "editorModeSeparator"]) {
 | 
				
			||||||
          document.getElementById("editorModeButtons"),
 | 
					          document.getElementById(id)?.classList.add("hidden");
 | 
				
			||||||
          document.getElementById("editorModeSeparator"),
 | 
					 | 
				
			||||||
        ]) {
 | 
					 | 
				
			||||||
          element.hidden = true;
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -792,16 +789,13 @@ const PDFViewerApplication = {
 | 
				
			|||||||
   * @private
 | 
					   * @private
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  _hideViewBookmark() {
 | 
					  _hideViewBookmark() {
 | 
				
			||||||
    const { viewBookmarkButton, presentationModeButton } =
 | 
					    const { secondaryToolbar } = this.appConfig;
 | 
				
			||||||
      this.appConfig.secondaryToolbar;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // URL does not reflect proper document location - hiding some buttons.
 | 
					    // URL does not reflect proper document location - hiding some buttons.
 | 
				
			||||||
    viewBookmarkButton.hidden = true;
 | 
					    secondaryToolbar?.viewBookmarkButton.classList.add("hidden");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Avoid displaying multiple consecutive separators in the secondaryToolbar.
 | 
					    // Avoid displaying multiple consecutive separators in the secondaryToolbar.
 | 
				
			||||||
    if (presentationModeButton.hidden) {
 | 
					    if (secondaryToolbar?.presentationModeButton.classList.contains("hidden")) {
 | 
				
			||||||
      const element = document.getElementById("viewBookmarkSeparator");
 | 
					      document.getElementById("viewBookmarkSeparator")?.classList.add("hidden");
 | 
				
			||||||
      element.hidden = true;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -2175,8 +2169,8 @@ function webViewerInitialized() {
 | 
				
			|||||||
    appConfig.secondaryToolbar?.printButton.classList.add("hidden");
 | 
					    appConfig.secondaryToolbar?.printButton.classList.add("hidden");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (appConfig.secondaryToolbar && !PDFViewerApplication.supportsFullscreen) {
 | 
					  if (!PDFViewerApplication.supportsFullscreen) {
 | 
				
			||||||
    appConfig.secondaryToolbar.presentationModeButton.hidden = true;
 | 
					    appConfig.secondaryToolbar?.presentationModeButton.classList.add("hidden");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (PDFViewerApplication.supportsIntegratedFind) {
 | 
					  if (PDFViewerApplication.supportsIntegratedFind) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user