You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by jg...@apache.org on 2026/06/25 16:50:18 UTC
(xmlgraphics-fop) branch main updated: FOP-3323 Prevent NPE when adding invalid property to fo:title
This is an automated email from the ASF dual-hosted git repository.
joao12021996 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/xmlgraphics-fop.git
The following commit(s) were added to refs/heads/main by this push:
new 8e4a19cf2 FOP-3323 Prevent NPE when adding invalid property to fo:title
8e4a19cf2 is described below
commit 8e4a19cf214ddfc27ad1d03fa04a14e717f6ce0a
Author: Joao Goncalves <an...@gmail.com>
AuthorDate: Thu Jun 18 13:19:17 2026 -0500
FOP-3323 Prevent NPE when adding invalid property to fo:title
---
.../AbstractPageSequenceLayoutManager.java | 2 +-
.../layoutengine/standard-testcases/title_id.xml | 45 ++++++++++++++++++++++
2 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java
index ad2112bbc..20e299f58 100644
--- a/fop-core/src/main/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java
+++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java
@@ -153,7 +153,7 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa
* @param id the ID reference to add
*/
public void addIDToPage(String id) {
- if (id != null && id.length() > 0) {
+ if (id != null && !id.isEmpty() && curPage != null) {
idTracker.associateIDWithPageViewport(id, curPage.getPageViewport());
}
}
diff --git a/fop/test/layoutengine/standard-testcases/title_id.xml b/fop/test/layoutengine/standard-testcases/title_id.xml
new file mode 100644
index 000000000..fce183526
--- /dev/null
+++ b/fop/test/layoutengine/standard-testcases/title_id.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+ <info>
+ <p>
+ This test checks that adding an invalid id property to fo:title does not cause a NPE.
+ </p>
+ </info>
+ <fo>
+ <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="A4"
+ page-height="297mm" page-width="210mm"
+ margin="20mm">
+ <fo:region-body/>
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+ <fo:page-sequence master-reference="A4">
+ <fo:title id="t1">Hello World</fo:title>
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block id="test">Hello World!</fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+ </fo:root>
+ </fo>
+ <checks>
+ <eval expected="Hello World!" xpath="//flow/block"/>
+ </checks>
+</testcase>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org