Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KItinerary
Commits
f09b26d3
Commit
f09b26d3
authored
May 19, 2021
by
Volker Krause
Browse files
Fix parsing of BCBPs that claim to have a zero-length conditioanl block
Found e.g. in some Qatar Airways boarding passes.
parent
7a11d89f
Changes
4
Hide whitespace changes
Inline
Side-by-side
autotests/bcbpdata/qatar-zero-size-conditional-section.json
0 → 100644
View file @
f09b26d3
[
{
"@context"
:
"http://schema.org"
,
"@type"
:
"FlightReservation"
,
"airplaneSeat"
:
"42F"
,
"passengerSequenceNumber"
:
"23"
,
"reservationFor"
:
{
"@type"
:
"Flight"
,
"airline"
:
{
"@type"
:
"Airline"
,
"iataCode"
:
"QR"
},
"arrivalAirport"
:
{
"@type"
:
"Airport"
,
"iataCode"
:
"DOH"
},
"departureAirport"
:
{
"@type"
:
"Airport"
,
"iataCode"
:
"MXP"
},
"departureDay"
:
"2018-09-13"
,
"flightNumber"
:
"128"
},
"reservationNumber"
:
"XXX007"
,
"reservationStatus"
:
"http://schema.org/ReservationConfirmed"
,
"reservedTicket"
:
{
"@type"
:
"Ticket"
,
"ticketToken"
:
"aztecCode:M1DOE/JANE EXXX007 MXPDOHQR 0128 256Y042F0023 100>2180 0255BBR 2963456000789980 0"
},
"underName"
:
{
"@type"
:
"Person"
,
"familyName"
:
"DOE"
,
"givenName"
:
"JANE"
}
}
]
autotests/bcbpdata/qatar-zero-size-conditional-section.txt
0 → 100644
View file @
f09b26d3
IATA Barcoded Boarding Pass
formatCode: M
numberOfLegs: 1
passengerName: DOE/JANE
electronicTicketIndicator: E
version: 0
fieldSize: 0
passengerDescription:
sourceOfCheckin:
sourceOfBoardingPassIssuance:
yearOfIssue: 0
dayOfIssue: 0
documentType:
airlineDesignatorOfBoardingPassIssuer:
baggageTagLicensePlateNumber1:
baggageTagLicensePlateNumber2:
baggageTagLicensePlateNumber3:
Date of issue:
Leg 1
operatingCarrierPNRCode: XXX007
fromCityAirportCode: MXP
toCityAirportCode: DOH
operatingCarrierDesignator: QR
flightNumber: 0128
dayOfFlight: 256
compartmentCode: Y
seatNumber: 042F
checkinSequenceNumber: 0023
passengerStatus: 1
variableFieldSize: 0
conditionalFieldSize: 0
airlineNumericCode:
documentNumber:
selecteeIndicator:
internationalDocumentVerification:
marketingCarrierDesignator:
frequentFlyerAirlineDesignator:
frequenFlyerNumber:
idAdIndicator:
freeBaggageAllowance:
fastTrack:
Airline use section:
Date of flight: 2018-09-13
autotests/bcbpparsertest.cpp
View file @
f09b26d3
...
...
@@ -55,6 +55,8 @@ private Q_SLOTS:
// TAP missing boarding pass issue date
QTest
::
newRow
(
"no issue date"
)
<<
QStringLiteral
(
"M1DOE/JOHN EXXX007 LISLCGTP 1080 204Y002D0003 35C>2180 B1A 2904712345678900 *306 09 BRND"
)
<<
QStringLiteral
(
"tap-missing-issue-date"
);
// Qatar claiming zero-length field sizes
QTest
::
newRow
(
"zero size conditional"
)
<<
QStringLiteral
(
"M1DOE/JANE EXXX007 MXPDOHQR 0128 256Y042F0023 100>2180 0255BBR 2963456000789980 0"
)
<<
QStringLiteral
(
"qatar-zero-size-conditional-section"
);
}
void
testParserValid
()
...
...
@@ -87,6 +89,9 @@ private Q_SLOTS:
QCOMPARE
(
proc
.
exitCode
(),
0
);
if
(
ticketDump
!=
refOut
)
{
qDebug
().
noquote
()
<<
ticketDump
;
QFile
failFile
(
ref
.
fileName
()
+
QLatin1String
(
".fail"
));
QVERIFY
(
failFile
.
open
(
QFile
::
WriteOnly
));
failFile
.
write
(
ticketDump
);
}
QVERIFY
(
ticketDump
==
refOut
);
...
...
@@ -100,6 +105,9 @@ private Q_SLOTS:
if
(
refArray
!=
resJson
)
{
qWarning
().
noquote
()
<<
QJsonDocument
(
resJson
).
toJson
();
QFile
failFile
(
f
.
fileName
()
+
QLatin1String
(
".fail"
));
QVERIFY
(
failFile
.
open
(
QFile
::
WriteOnly
));
failFile
.
write
(
QJsonDocument
(
resJson
).
toJson
());
}
QCOMPARE
(
resJson
,
refArray
);
}
...
...
src/lib/iata/iatabcbp.cpp
View file @
f09b26d3
...
...
@@ -66,12 +66,17 @@ IataBcbpUniqueMandatorySection IataBcbp::uniqueMandatorySection() const
bool
IataBcbp
::
hasUniqueConditionalSection
()
const
{
return
(
m_data
.
size
()
>
(
UniqueMandatorySize
+
RepeatedMandatorySize
))
&&
(
m_data
.
at
(
UniqueMandatorySize
+
RepeatedMandatorySize
)
==
QLatin1Char
(
'>'
));
return
(
m_data
.
size
()
>
(
UniqueMandatorySize
+
RepeatedMandatorySize
))
&&
(
m_data
.
at
(
UniqueMandatorySize
+
RepeatedMandatorySize
)
==
QLatin1Char
(
'>'
))
&&
repeatedMandatorySection
(
0
).
variableFieldSize
()
>
MinimumUniqueConditionalSize
;
}
IataBcbpUniqueConditionalSection
IataBcbp
::
uniqueConditionalSection
()
const
{
return
IataBcbpUniqueConditionalSection
(
QStringView
(
m_data
).
mid
(
UniqueMandatorySize
+
RepeatedMandatorySize
));
if
(
hasUniqueConditionalSection
())
{
return
IataBcbpUniqueConditionalSection
(
QStringView
(
m_data
).
mid
(
UniqueMandatorySize
+
RepeatedMandatorySize
));
}
return
IataBcbpUniqueConditionalSection
(
QStringView
());
}
IataBcbpRepeatedMandatorySection
IataBcbp
::
repeatedMandatorySection
(
int
leg
)
const
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment