You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by Andreas Lehmkuehler <an...@lehmi.de> on 2013/01/20 20:03:47 UTC
Re: svn commit: r1435877 - in /pdfbox/trunk: pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceN.java
preflight/src/main/java/org/apache/pdfbox/preflight/graphic/StandardColorSpaceHelper.java
Hi,
Am 20.01.2013 17:33, schrieb leleueri@apache.org:
> Author: leleueri
> Date: Sun Jan 20 16:33:31 2013
> New Revision: 1435877
>
> URL: http://svn.apache.org/viewvc?rev=1435877&view=rev
> Log:
> PDFBOX-1497 : avoid ArrayOutOfBound on PDDeviceN.getAttributes
>
> Modified:
> pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceN.java
> pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/graphic/StandardColorSpaceHelper.java
>
> Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceN.java
> URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceN.java?rev=1435877&r1=1435876&r2=1435877&view=diff
> ==============================================================================
> --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceN.java (original)
> +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceN.java Sun Jan 20 16:33:31 2013
> @@ -242,11 +242,16 @@ public class PDDeviceN extends PDColorSp
> {
> if ( deviceNAttributes == null )
> {
> + if (array.size() > DEVICEN_ATTRIBUTES) { // the DeviceN contains an attributes dictionary
> deviceNAttributes = new PDDeviceNAttributes((COSDictionary)array.getObject(DEVICEN_ATTRIBUTES));
> + } else {
> + // create the Attributes dictionary
> + setAttributes(new PDDeviceNAttributes());
> + }
Hmm, IMHO it doesn't make sense to return an instance of PDDeviceNAttributes
if there isn't any value, because it is optional. Furthermore it won't make
sense to add a hasAttributes method if the get method always returns a something
other than null.
> }
> return deviceNAttributes;
> }
> -
> +
> /**
> * This will set the color space attributes. If null is passed in then
> * all attribute will be removed.
> @@ -272,6 +277,15 @@ public class PDDeviceN extends PDColorSp
> }
>
> /**
> + * Returns true if the DeviceN color space has an attributes dictionary
> + * @return
> + */
> + public boolean hasAttributes()
> + {
> + return array.size() > DEVICEN_ATTRIBUTES;
> + }
> +
> + /**
> * Returns the components of the color in the alternate colorspace for the given tint value.
> * @param tintValues a list containing the tint values
> * @return COSArray with the color components
>
SNIP
BR
Andreas Lehmkühler
Re: svn commit: r1435877 - in /pdfbox/trunk: pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceN.java
preflight/src/main/java/org/apache/pdfbox/preflight/graphic/StandardColorSpaceHelper.java
Posted by Andreas Lehmkuehler <an...@lehmi.de>.
Hi,
Am 21.01.2013 20:05, schrieb Leleu Eric:
> Hi,
>
> Indeed, I updated the code in the revision r1436553.
Thanks for the quick response!
>
> BR,
> Eric
>
BR
Andreas Lehmkühler
>
> 2013/1/20 Andreas Lehmkuehler <an...@lehmi.de>
>
>> Hi,
>>
>> Am 20.01.2013 17:33, schrieb leleueri@apache.org:
>>
>>> Author: leleueri
>>> Date: Sun Jan 20 16:33:31 2013
>>> New Revision: 1435877
>>>
>>> URL: http://svn.apache.org/viewvc?**rev=1435877&view=rev<http://svn.apache.org/viewvc?rev=1435877&view=rev>
>>> Log:
>>> PDFBOX-1497 : avoid ArrayOutOfBound on PDDeviceN.getAttributes
>>>
>>> Modified:
>>> pdfbox/trunk/pdfbox/src/main/**java/org/apache/pdfbox/**
>>> pdmodel/graphics/color/**PDDeviceN.java
>>> pdfbox/trunk/preflight/src/**main/java/org/apache/pdfbox/**
>>> preflight/graphic/**StandardColorSpaceHelper.java
>>>
>>> Modified: pdfbox/trunk/pdfbox/src/main/**java/org/apache/pdfbox/**
>>> pdmodel/graphics/color/**PDDeviceN.java
>>> URL: http://svn.apache.org/viewvc/**pdfbox/trunk/pdfbox/src/main/**
>>> java/org/apache/pdfbox/**pdmodel/graphics/color/**
>>> PDDeviceN.java?rev=1435877&r1=**1435876&r2=1435877&view=diff<http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceN.java?rev=1435877&r1=1435876&r2=1435877&view=diff>
>>> ==============================**==============================**
>>> ==================
>>> --- pdfbox/trunk/pdfbox/src/main/**java/org/apache/pdfbox/**
>>> pdmodel/graphics/color/**PDDeviceN.java (original)
>>> +++ pdfbox/trunk/pdfbox/src/main/**java/org/apache/pdfbox/**
>>> pdmodel/graphics/color/**PDDeviceN.java Sun Jan 20 16:33:31 2013
>>> @@ -242,11 +242,16 @@ public class PDDeviceN extends PDColorSp
>>> {
>>> if ( deviceNAttributes == null )
>>> {
>>> + if (array.size() > DEVICEN_ATTRIBUTES) { // the DeviceN
>>> contains an attributes dictionary
>>> deviceNAttributes = new PDDeviceNAttributes((**
>>> COSDictionary)array.getObject(**DEVICEN_ATTRIBUTES));
>>> + } else {
>>> + // create the Attributes dictionary
>>> + setAttributes(new PDDeviceNAttributes());
>>> + }
>>>
>> Hmm, IMHO it doesn't make sense to return an instance of
>> PDDeviceNAttributes
>> if there isn't any value, because it is optional. Furthermore it won't make
>> sense to add a hasAttributes method if the get method always returns a
>> something
>> other than null.
>>
>> }
>>> return deviceNAttributes;
>>> }
>>> -
>>> +
>>> /**
>>> * This will set the color space attributes. If null is passed in
>>> then
>>> * all attribute will be removed.
>>> @@ -272,6 +277,15 @@ public class PDDeviceN extends PDColorSp
>>> }
>>>
>>> /**
>>> + * Returns true if the DeviceN color space has an attributes
>>> dictionary
>>> + * @return
>>> + */
>>> + public boolean hasAttributes()
>>> + {
>>> + return array.size() > DEVICEN_ATTRIBUTES;
>>> + }
>>> +
>>> + /**
>>> * Returns the components of the color in the alternate colorspace
>>> for the given tint value.
>>> * @param tintValues a list containing the tint values
>>> * @return COSArray with the color components
>>>
>>> SNIP
>>
>> BR
>> Andreas Lehmkühler
>>
>>
>
Re: svn commit: r1435877 - in /pdfbox/trunk: pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceN.java
preflight/src/main/java/org/apache/pdfbox/preflight/graphic/StandardColorSpaceHelper.java
Posted by Leleu Eric <er...@gmail.com>.
Hi,
Indeed, I updated the code in the revision r1436553.
BR,
Eric
2013/1/20 Andreas Lehmkuehler <an...@lehmi.de>
> Hi,
>
> Am 20.01.2013 17:33, schrieb leleueri@apache.org:
>
>> Author: leleueri
>> Date: Sun Jan 20 16:33:31 2013
>> New Revision: 1435877
>>
>> URL: http://svn.apache.org/viewvc?**rev=1435877&view=rev<http://svn.apache.org/viewvc?rev=1435877&view=rev>
>> Log:
>> PDFBOX-1497 : avoid ArrayOutOfBound on PDDeviceN.getAttributes
>>
>> Modified:
>> pdfbox/trunk/pdfbox/src/main/**java/org/apache/pdfbox/**
>> pdmodel/graphics/color/**PDDeviceN.java
>> pdfbox/trunk/preflight/src/**main/java/org/apache/pdfbox/**
>> preflight/graphic/**StandardColorSpaceHelper.java
>>
>> Modified: pdfbox/trunk/pdfbox/src/main/**java/org/apache/pdfbox/**
>> pdmodel/graphics/color/**PDDeviceN.java
>> URL: http://svn.apache.org/viewvc/**pdfbox/trunk/pdfbox/src/main/**
>> java/org/apache/pdfbox/**pdmodel/graphics/color/**
>> PDDeviceN.java?rev=1435877&r1=**1435876&r2=1435877&view=diff<http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceN.java?rev=1435877&r1=1435876&r2=1435877&view=diff>
>> ==============================**==============================**
>> ==================
>> --- pdfbox/trunk/pdfbox/src/main/**java/org/apache/pdfbox/**
>> pdmodel/graphics/color/**PDDeviceN.java (original)
>> +++ pdfbox/trunk/pdfbox/src/main/**java/org/apache/pdfbox/**
>> pdmodel/graphics/color/**PDDeviceN.java Sun Jan 20 16:33:31 2013
>> @@ -242,11 +242,16 @@ public class PDDeviceN extends PDColorSp
>> {
>> if ( deviceNAttributes == null )
>> {
>> + if (array.size() > DEVICEN_ATTRIBUTES) { // the DeviceN
>> contains an attributes dictionary
>> deviceNAttributes = new PDDeviceNAttributes((**
>> COSDictionary)array.getObject(**DEVICEN_ATTRIBUTES));
>> + } else {
>> + // create the Attributes dictionary
>> + setAttributes(new PDDeviceNAttributes());
>> + }
>>
> Hmm, IMHO it doesn't make sense to return an instance of
> PDDeviceNAttributes
> if there isn't any value, because it is optional. Furthermore it won't make
> sense to add a hasAttributes method if the get method always returns a
> something
> other than null.
>
> }
>> return deviceNAttributes;
>> }
>> -
>> +
>> /**
>> * This will set the color space attributes. If null is passed in
>> then
>> * all attribute will be removed.
>> @@ -272,6 +277,15 @@ public class PDDeviceN extends PDColorSp
>> }
>>
>> /**
>> + * Returns true if the DeviceN color space has an attributes
>> dictionary
>> + * @return
>> + */
>> + public boolean hasAttributes()
>> + {
>> + return array.size() > DEVICEN_ATTRIBUTES;
>> + }
>> +
>> + /**
>> * Returns the components of the color in the alternate colorspace
>> for the given tint value.
>> * @param tintValues a list containing the tint values
>> * @return COSArray with the color components
>>
>> SNIP
>
> BR
> Andreas Lehmkühler
>
>